vonDarkmoor
New Member
- Reaction score
- 9
Ok so i got a map that has the Camera Following a unit from behind and close up. as the unit runs around the camera rotates with the unit staying on the back, using the following code:
This part works fine as far as i know. YOU 0000 <gen> is the unit.
The part i am having trouble with is the arrow key movement, the forward works fine with :
+
+
Now i tried to use this same method for the rotation. I want the Left and Right arrow keys to rotate the unit. I couldnt find any "Rotate Unit" function so i order the unit to move to a position to the units right based on the units facing angle with the movement distance being ordered equal to 0. so the units turns toward the direction its ordered to turn then moves 0.
However the problem i am having is the unit will only move to the right and wont turn past a facing angle of 0. Here is the code.
I use the same Trigger-Turn on/off Triggers as with the forward movement.
I use the same code for Left turn except i did
The text display is just for testing to show me what angle its facing, whats happening is regardless of whether i press the Left or Right Arrow Key the unit turns to the Right and the Angle will subtract to 0 then the Unit stops moving even if i continue to press the Left or Right Arrow Key.
I tried adding :
But the unit would still not move and all that changed was the Text displayed now said 360 instead of 0.
I know there are going to be a lot of leaks with this system, i am just learning about leaks and once i get a system that works, ill go back and alter it to remove the memory leaks.
Also i did do a search for unit movement with arrow Keys, but i couldn't' find one that dealt with rotating a unit with arrow Keys.
Any Help would be greatly appreciated.
Trigger:
- Camera
- Events
- Time - Every 0.01 seconds of game time
- Conditions
- Actions
- Camera - Pan camera for Player 1 (Red) to (Position of YOU 0000 <gen>) over 0.00 seconds
- Camera - Set Player 1 (Red)'s camera Rotation to (Facing of YOU 0000 <gen>) over 0.00 seconds
- Camera - Set Player 1 (Red)'s camera Angle of attack to 330.00 over 0.00 seconds
- Camera - Set Player 1 (Red)'s camera Field of view to 70.00 over 0.00 seconds
- Camera - Set Player 1 (Red)'s camera Distance to target to 400.00 over 0.00 seconds
- Camera - Set Player 1 (Red)'s camera Height Offset to 150.00 over 0.00 seconds
- Camera - Lock camera target for Player 1 (Red) to YOU 0000 <gen>, offset by (0.00, 0.00) using The unit's rotation
- Events
This part works fine as far as i know. YOU 0000 <gen> is the unit.
The part i am having trouble with is the arrow key movement, the forward works fine with :
Trigger:
- Start Up Movement
- Events
- Player - Player 1 (Red) Presses the Up Arrow key
- Conditions
- Actions
- Trigger - Turn on Up Movement <gen>
- Events
+
Trigger:
- Up Movement
- Events
- Time - Every 0.05 seconds of game time
- Conditions
- Actions
- Unit - Order YOU 0000 <gen> to Move To ((Position of YOU 0000 <gen>) offset by 100.00 towards (Facing of YOU 0000 <gen>) degrees)
- Events
+
Trigger:
- End Up Movement
- Events
- Player - Player 1 (Red) Releases the Up Arrow key
- Conditions
- Actions
- Trigger - Turn off Up Movement <gen>
- Events
Now i tried to use this same method for the rotation. I want the Left and Right arrow keys to rotate the unit. I couldnt find any "Rotate Unit" function so i order the unit to move to a position to the units right based on the units facing angle with the movement distance being ordered equal to 0. so the units turns toward the direction its ordered to turn then moves 0.
However the problem i am having is the unit will only move to the right and wont turn past a facing angle of 0. Here is the code.
I use the same Trigger-Turn on/off Triggers as with the forward movement.
Trigger:
- Right Turn
- Events
- Time - Every 0.05 seconds of game time
- Conditions
- Actions
- Set Unit_Angle = (Facing of YOU 0000 <gen>)
- Unit - Order YOU 0000 <gen> to Move To ((Position of YOU 0000 <gen>) offset by 0.00 towards (Unit_Angle - 1.00) degrees)
- Game - Display to (All players) the text: (String(Unit_Angle))
- Events
I use the same code for Left turn except i did
Trigger:
- Unit - Order YOU 0000 <gen> to Move To ((Position of YOU 0000 <gen>) offset by 0.00 towards (Unit_Angle + 1.00) degrees)
The text display is just for testing to show me what angle its facing, whats happening is regardless of whether i press the Left or Right Arrow Key the unit turns to the Right and the Angle will subtract to 0 then the Unit stops moving even if i continue to press the Left or Right Arrow Key.
I tried adding :
Trigger:
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Unit_Angle Equal to 0.00
- Then - Actions
- Set Unit_Angle = 360.00
- Else - Actions
- If - Conditions
But the unit would still not move and all that changed was the Text displayed now said 360 instead of 0.
I know there are going to be a lot of leaks with this system, i am just learning about leaks and once i get a system that works, ill go back and alter it to remove the memory leaks.
Also i did do a search for unit movement with arrow Keys, but i couldn't' find one that dealt with rotating a unit with arrow Keys.
Any Help would be greatly appreciated.