Scripts / Entities Turning

Author
Message
GoDevils
10
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 13th Apr 2015 13:51
From Lee's April 10th Blog

Quote: "Updated CITYSCAPE entities to reset any ROTY rotations causing odd angles"



I've been trying to develop a script which allows an entity (like a car) to move forward and turn. Moving forward is fine, but the turns are hard to control. The objective was a script using only local variables so I could reuse the basic script for multiple entities, and have many of them running at the same time.

I first attempted a turn generated by a set of MoveForward and RotateY commands, and it works, except when the game's FPS goes up or down, the turn goes wrong, usually forcing the entity to over rotate.

I then tried constructing a turn using ResetPosition and SetRotation commands. This seemed to work at first, but if I let the sequence run over and over, at some point something goes wrong and the turn goes crazy sending the entity off in the wrong direction.

The entire script is too big to post here, but here are two segments. The first is the the turn using RotateY, and the 2nd using ResetPosition.



And here is the segment using ResetPosition



Both systems automatically reset and then perform the movement sequences again and again. In the later code, the strange thing is that it will work for several reps, and then suddenly for no reason the turn is completely wrong (backwards, turning the wrong way, etc). ??

I'm stumped. I thought of trying to control the first code by making sure that it did not over-rotate, but there is no way to GET or calculate the rotation angle of the entity from the engine. In the 2nd code I tried making each control variable different, but the problem persists.

Anyone have any ideas???

Thanks


"THERE IS NO SPOON"

AMD 6300 6 core 3.5 ghz, Windows 8.1, 8GB ram, GTX 650 2GB ram
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Apr 2015 14:42
the second one is definitely the best one to use
i dont see any code there to reset those angles though, when you restart the "loop" as it were you need to put the angles back to 0 (or whatever you have them as at the start) otherwise i guess they are going above 360 and causing the issue?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
GoDevils
10
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 15th Apr 2015 20:36
Thanks smallg.

I found that the issue was a single variable that I had not defined as local.
Now it is working correctly.

"THERE IS NO SPOON"

AMD 6300 6 core 3.5 ghz, Windows 8.1, 8GB ram, GTX 650 2GB ram

Login to post a reply

Server time is: 2024-12-21 13:52:14
Your offset time is: 2024-12-21 13:52:14