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.
AAMove1=ACDCadd
if MvFrd == 1 then MoveForward(e,AAMove1) else MoveBackward(e,AAMove1)
end
--MoveBackward (e,AAMove1) -- move entity command sent to engine
-- point at which turn is activated
if ObjPoint[7] > 0 then
TurnCount = TurnCount + 1
RotateY(e,ObjPoint[6])
if TurnCount == ObjPoint[10] then
ObjPoint[7] = 0
TurnCount = 0
SetRotation(e,0,ObjPoint[12],0) -- the wiggle to get direction correct
end
And here is the segment using ResetPosition
::PC2:: -- Turn is executed
IncreStartXX = IncreStartXX + IncreXX
aa_Mover1xx2 = g_Entity[e] ['x'] + IncreStartXX
IncreStartZZ = IncreStartZZ + IncreZZ
aa_Mover1zz2 = g_Entity[e] ['z'] + IncreStartZZ
ResetPosition(e,aa_Mover1xx2, 623, aa_Mover1zz2)
aa_IncreTurnStart2 = aa_IncreTurnStart2 + IncreTurn
SetRotation(e,0,aa_IncreTurnStart2,0)
Counter1 = Counter1 + 1
if Counter1 == Countertot then Counter1 = 0;Passcode2 = 1
aa_Mover1xx2 = 0
aa_Mover1zz2 = 0
Passcode1=3
end
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