• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

3rd Person Camera + Smooth Arrow Key Movement 1.4

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
I didn't found any good movement system with smooth camera, so i decided to make one. This one will lock the camera to the selected unit, rotate the camera as the unit is rotating, while also it will move the unit and rotate it with the arrow keys.Basically it's a racing system for car games.

Features:
-3 custom stats that can be used in a game: Acceleration,Handling,Top speed (excellent for car games)
-Movement speed well beyond 522 as it moves with custom trigger (also FPS remains good no memory leaks)
-Animation added when unit moves, no sliding bug,its realistic
-Camera locks and rotates with unit
-Arrow keys used to move the unit, memory leak free and quick
-11 Player compatible (multiplayer, except player 12 which must be a computer)
-Car decelerates smoothly if its accelerated by pressing the DOWN key
-Easy to copy into your map


[From 1.0 to 1.1]
-Fixed sliding bug (fractional division leftover could cause the car to not stop is fixed)
-Fixed acceleration/deceleration sync, now you can do both at a time and it will add/subtract from the current speed
-Added custom car model and horn effect
-Reworked the triggers and removed unnecesary variables
-Added speedometer, however it might memory leak, but it is not meant to use in the main system, it is just for misc/debug stuff for now, the main system is MOVEMENTSYSTEM folder, everything else is misc or init stuff

[From 1.1 to 1.2]
-Camera made smoother
-Made deceleration speed balanced, while the backwards speed is slower than the forward speed
-Added collision system (destructibles and units gets killed if hit by car)
-Also car decelerates if hits a destructible or doodoead
-Fixed a few misc bugs
-As deathismyfriend suggested, i added the loop into a player force to be more efficient while adding a variable for player_nr_of_picked_player

[From 1.2 to 1.3]
-Player group variable only declared once and never deleted

[From 1.3 to 1.4]
-Added temp variables for picked player and triggering player
-Resolved the wait issue, not by indexing but by an even better way to force the action into the event trigger instead of waiting until the periodic trigger gets triggered, so this way if a player presses the LEFT/RIGHT key and quickly releases it, the car still gets steered by STATS_HANDLING*1.5 amount
-Init is now at 0.00 elapsed time
-Renamed variables to be more easily readable
-Reconfigured some stuff



-Car immediately stops after hitting a doodoad, but it only gets slowed down by normal units (it doesnt slide by as it is doing now , with top speed , after collision)
-Reworking camera to be more smooth
-General optimization of both aestethic and memory conservation fields
-Fixing unknown bugs


Parameters:
- STATS_ACCELERATION= sets the acceleration amount of the car
- STATS_TOPSPEED= the car accelerates until it reaches top speed
- STATS_HANDLING= the speed of rotation of the car

====================================================



[trigger="Init"]
INIT
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Visibility - Disable fog of war
Visibility - Disable black mask
Set Group_Playing_Players = (All players controlled by a User player)
Player Group - Pick every player in Group_Playing_Players and do (Actions)
Loop - Actions
Set The_Picked_Player = (Picked player)
-------- =====================TESTIFPLAYERLEFTORNOT==================== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(The_Picked_Player slot status) Equal to Is playing
Then - Actions
-------- ========================INIT VARIABLES============================ --------
Set Player_Number_of_Picked_Player = (Player number of The_Picked_Player)
-------- ========================CAMERA============================ --------
Set Point_of_Creation = (Random point in carz <gen>)
Unit - Create 1 Soviet Car for The_Picked_Player at Point_of_Creation facing Default building facing degrees
Custom script: call RemoveLocation (udg_Point_of_Creation)
Set My_Car[Player_Number_of_Picked_Player] = (Last created unit)
Selection - Select My_Car[Player_Number_of_Picked_Player] for The_Picked_Player
Camera - Lock camera target for The_Picked_Player to My_Car[Player_Number_of_Picked_Player], offset by (0.00, 0.00) using The unit's rotation
Camera - Set The_Picked_Player's camera Far Z to 25000.00 over 0.00 seconds
-------- 300-350 --------
Camera - Set The_Picked_Player's camera Angle of attack to 330.00 over 0.00 seconds
Camera - Set The_Picked_Player's camera Distance to target to 1200.00 over 0.00 seconds
Camera - Set The_Picked_Player's camera Height Offset to 350.00 over 0.00 seconds
Else - Actions
Trigger - Turn on PERIODICxxxMAINxxTRIGGER <gen>
Trigger - Turn off (This trigger)

[/trigger]



[trigger="Periodic Main Refresh Trigger"]
PERIODICxxxMAINxxTRIGGER
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
Player Group - Pick every player in Group_Playing_Players and do (Actions)
Loop - Actions
Set The_Picked_Player = (Picked player)
-------- =====================TESTIFPLAYERLEFTORNOT==================== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(The_Picked_Player slot status) Equal to Is playing
Then - Actions
-------- ========================INIT VARIABLES============================ --------
Set Player_Number_of_Picked_Player = (Player number of The_Picked_Player)
-------- ========================ROTATION SECTION============================ --------
Camera - Set The_Picked_Player's camera Rotation to (Facing of My_Car[Player_Number_of_Picked_Player]) over 0.30 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Rotation_Left[Player_Number_of_Picked_Player] Equal to True
Then - Actions
Unit - Make My_Car[Player_Number_of_Picked_Player] face ((Facing of My_Car[Player_Number_of_Picked_Player]) + STATS_HANDLING[Player_Number_of_Picked_Player]) over 0.00 seconds
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Rotation_Right[Player_Number_of_Picked_Player] Equal to True
Then - Actions
Unit - Make My_Car[Player_Number_of_Picked_Player] face ((Facing of My_Car[Player_Number_of_Picked_Player]) - STATS_HANDLING[Player_Number_of_Picked_Player]) over 0.00 seconds
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
-------- ========================MOVEMENT SECTION============================ --------
-------- ==[FORWARD ACCELERATION]== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Ahead_Move[Player_Number_of_Picked_Player] Equal to True
Ahead_Decelerate[Player_Number_of_Picked_Player] Equal to False
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current_Speed_Variable[Player_Number_of_Picked_Player] + STATS_ACCELERATION[Player_Number_of_Picked_Player]) Less than or equal to STATS_TOPSPEED[Player_Number_of_Picked_Player]
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = (Current_Speed_Variable[Player_Number_of_Picked_Player] + STATS_ACCELERATION[Player_Number_of_Picked_Player])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than (STATS_TOPSPEED[Player_Number_of_Picked_Player] - 1.00)
Current_Speed_Variable[Player_Number_of_Picked_Player] Less than STATS_TOPSPEED[Player_Number_of_Picked_Player]
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = STATS_TOPSPEED[Player_Number_of_Picked_Player]
Else - Actions
Set Point_of_Path[Player_Number_of_Picked_Player] = ((Position of My_Car[Player_Number_of_Picked_Player]) offset by Current_Speed_Variable[Player_Number_of_Picked_Player] towards (Facing of My_Car[Player_Number_of_Picked_Player]) degrees)
Unit - Move My_Car[Player_Number_of_Picked_Player] instantly to Point_of_Path[Player_Number_of_Picked_Player]
Custom script: call RemoveLocation (udg_Point_of_Path[udg_Player_Number_of_Picked_Player])
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
-------- ==[FORWARD DECELARATION]== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Ahead_Move[Player_Number_of_Picked_Player] Equal to False
Ahead_Decelerate[Player_Number_of_Picked_Player] Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current_Speed_Variable[Player_Number_of_Picked_Player] - STATS_ACCELERATION[Player_Number_of_Picked_Player]) Greater than or equal to 0.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = (Current_Speed_Variable[Player_Number_of_Picked_Player] - STATS_ACCELERATION[Player_Number_of_Picked_Player])
Else - Actions
-------- IF THE REMAINING SPEED IS VERY SMALL THEN AUTOMATICALLY STOP AND NOT SLIDE --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than 0.00
Current_Speed_Variable[Player_Number_of_Picked_Player] Less than 1.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = 0.00
Else - Actions
Set Point_of_Path[Player_Number_of_Picked_Player] = ((Position of My_Car[Player_Number_of_Picked_Player]) offset by Current_Speed_Variable[Player_Number_of_Picked_Player] towards (Facing of My_Car[Player_Number_of_Picked_Player]) degrees)
Unit - Move My_Car[Player_Number_of_Picked_Player] instantly to Point_of_Path[Player_Number_of_Picked_Player]
Custom script: call RemoveLocation (udg_Point_of_Path[udg_Player_Number_of_Picked_Player])
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
-------- ==[BACKWARD ACCELERATION]== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Backwards_Move[Player_Number_of_Picked_Player] Equal to True
Backwards_Decelerate[Player_Number_of_Picked_Player] Equal to False
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current_Speed_Variable[Player_Number_of_Picked_Player] - (STATS_ACCELERATION[Player_Number_of_Picked_Player] / 3.00)) Greater than or equal to (0.00 - (STATS_TOPSPEED[Player_Number_of_Picked_Player] / 7.00))
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = (Current_Speed_Variable[Player_Number_of_Picked_Player] - (STATS_ACCELERATION[Player_Number_of_Picked_Player] / 3.00))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Current_Speed_Variable[Player_Number_of_Picked_Player] Less than ((0.00 - STATS_TOPSPEED[Player_Number_of_Picked_Player]) + 1.00)
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than (0.00 - STATS_TOPSPEED[Player_Number_of_Picked_Player])
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = (0.00 - STATS_TOPSPEED[Player_Number_of_Picked_Player])
Else - Actions
Set Point_of_Path[Player_Number_of_Picked_Player] = ((Position of My_Car[Player_Number_of_Picked_Player]) offset by Current_Speed_Variable[Player_Number_of_Picked_Player] towards (Facing of My_Car[Player_Number_of_Picked_Player]) degrees)
Unit - Move My_Car[Player_Number_of_Picked_Player] instantly to Point_of_Path[Player_Number_of_Picked_Player]
Custom script: call RemoveLocation (udg_Point_of_Path[udg_Player_Number_of_Picked_Player])
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
-------- ==[BACKWARD DECELERATION]== --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Backwards_Move[Player_Number_of_Picked_Player] Equal to False
Backwards_Decelerate[Player_Number_of_Picked_Player] Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current_Speed_Variable[Player_Number_of_Picked_Player] + (STATS_ACCELERATION[Player_Number_of_Picked_Player] / 2.00)) Less than or equal to 0.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = (Current_Speed_Variable[Player_Number_of_Picked_Player] + (STATS_ACCELERATION[Player_Number_of_Picked_Player] / 2.00))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Current_Speed_Variable[Player_Number_of_Picked_Player] Less than 0.00
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than -1.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = 0.00
Else - Actions
Set Point_of_Path[Player_Number_of_Picked_Player] = ((Position of My_Car[Player_Number_of_Picked_Player]) offset by Current_Speed_Variable[Player_Number_of_Picked_Player] towards (Facing of My_Car[Player_Number_of_Picked_Player]) degrees)
Unit - Move My_Car[Player_Number_of_Picked_Player] instantly to Point_of_Path[Player_Number_of_Picked_Player]
Custom script: call RemoveLocation (udg_Point_of_Path[udg_Player_Number_of_Picked_Player])
Animation - Play My_Car[Player_Number_of_Picked_Player]'s walk animation
Else - Actions
-------- ========================COLLISION TEST============================ --------
Set Point_of_Path[Player_Number_of_Picked_Player] = ((Position of My_Car[Player_Number_of_Picked_Player]) offset by 10.00 towards (Facing of My_Car[Player_Number_of_Picked_Player]) degrees)
Set Region_Collision[Player_Number_of_Picked_Player] = (Region centered at Point_of_Path[Player_Number_of_Picked_Player] with size (300.00, 300.00))
Custom script: call RemoveLocation (udg_Point_of_Path[udg_Player_Number_of_Picked_Player])
-------- -------here --------
Destructible - Pick every destructible in Region_Collision[Player_Number_of_Picked_Player] and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked destructible) is alive) Equal to True
Then - Actions
Destructible - Kill (Picked destructible)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Abs(Current_Speed_Variable[Player_Number_of_Picked_Player])) - (STATS_ACCELERATION[Player_Number_of_Picked_Player] x 3.00)) Greater than 0.00
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than 0.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = ((Abs(Current_Speed_Variable[Player_Number_of_Picked_Player])) - (STATS_ACCELERATION[Player_Number_of_Picked_Player] x 3.00))
Else - Actions
Else - Actions
Set Group_Collision_Units = (Units in Region_Collision[Player_Number_of_Picked_Player] matching ((Owner of (Matching unit)) Equal to Player 12 (Brown)))
Unit Group - Pick every unit in Group_Collision_Units and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is alive) Equal to True
((Abs(Current_Speed_Variable[Player_Number_of_Picked_Player])) - (STATS_ACCELERATION[Player_Number_of_Picked_Player] x 25.00)) Greater than 0.00
Current_Speed_Variable[Player_Number_of_Picked_Player] Greater than 0.00
Then - Actions
Set Current_Speed_Variable[Player_Number_of_Picked_Player] = ((Abs(Current_Speed_Variable[Player_Number_of_Picked_Player])) - (STATS_ACCELERATION[Player_Number_of_Picked_Player] x 25.00))
Else - Actions
Unit - Kill (Picked unit)
Custom script: call DestroyGroup (udg_Group_Collision_Units)
Custom script: call RemoveRect(udg_Region_Collision[udg_Player_Number_of_Picked_Player])
Else - Actions

[/trigger]



[trigger="Press Left"]
LEFTxxPRESS
Events
Player - Player 1 (Red) Presses the Left Arrow key
Player - Player 2 (Blue) Presses the Left Arrow key
Player - Player 3 (Teal) Presses the Left Arrow key
Player - Player 4 (Purple) Presses the Left Arrow key
Player - Player 5 (Yellow) Presses the Left Arrow key
Player - Player 6 (Orange) Presses the Left Arrow key
Player - Player 7 (Green) Presses the Left Arrow key
Player - Player 8 (Pink) Presses the Left Arrow key
Player - Player 9 (Gray) Presses the Left Arrow key
Player - Player 10 (Light Blue) Presses the Left Arrow key
Player - Player 11 (Dark Green) Presses the Left Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==steering== --------
Set Rotation_Left[Player_Number_of_Trig_Player] = True
Unit - Make My_Car[Player_Number_of_Trig_Player] face ((Facing of My_Car[Player_Number_of_Trig_Player]) + (STATS_HANDLING[Player_Number_of_Trig_Player] x 1.50)) over 0.00 seconds
Animation - Play My_Car[Player_Number_of_Trig_Player]'s walk animation

[/trigger]



[trigger="Release Left"]
LEFTxxRELEASE
Events
Player - Player 1 (Red) Releases the Left Arrow key
Player - Player 2 (Blue) Releases the Left Arrow key
Player - Player 3 (Teal) Releases the Left Arrow key
Player - Player 4 (Purple) Releases the Left Arrow key
Player - Player 5 (Yellow) Releases the Left Arrow key
Player - Player 6 (Orange) Releases the Left Arrow key
Player - Player 7 (Green) Releases the Left Arrow key
Player - Player 8 (Pink) Releases the Left Arrow key
Player - Player 9 (Gray) Releases the Left Arrow key
Player - Player 10 (Light Blue) Releases the Left Arrow key
Player - Player 11 (Dark Green) Releases the Left Arrow key
Conditions
Actions
Set Rotation_Left[(Player number of (Triggering player))] = False

[/trigger]



[trigger="Press Right"]
RIGHTxxPRESS
Events
Player - Player 1 (Red) Presses the Right Arrow key
Player - Player 2 (Blue) Presses the Right Arrow key
Player - Player 3 (Teal) Presses the Right Arrow key
Player - Player 4 (Purple) Presses the Right Arrow key
Player - Player 5 (Yellow) Presses the Right Arrow key
Player - Player 6 (Orange) Presses the Right Arrow key
Player - Player 7 (Green) Presses the Right Arrow key
Player - Player 8 (Pink) Presses the Right Arrow key
Player - Player 9 (Gray) Presses the Right Arrow key
Player - Player 10 (Light Blue) Presses the Right Arrow key
Player - Player 11 (Dark Green) Presses the Right Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==steering== --------
Set Rotation_Right[Player_Number_of_Trig_Player] = True
Unit - Make My_Car[Player_Number_of_Trig_Player] face ((Facing of My_Car[Player_Number_of_Trig_Player]) - (STATS_HANDLING[Player_Number_of_Trig_Player] x 1.50)) over 0.00 seconds
Animation - Play My_Car[Player_Number_of_Trig_Player]'s walk animation

[/trigger]



[trigger="Release Right"]
RIGHTxxRELEASE
Events
Player - Player 1 (Red) Releases the Right Arrow key
Player - Player 2 (Blue) Releases the Right Arrow key
Player - Player 3 (Teal) Releases the Right Arrow key
Player - Player 4 (Purple) Releases the Right Arrow key
Player - Player 5 (Yellow) Releases the Right Arrow key
Player - Player 6 (Orange) Releases the Right Arrow key
Player - Player 7 (Green) Releases the Right Arrow key
Player - Player 8 (Pink) Releases the Right Arrow key
Player - Player 9 (Gray) Releases the Right Arrow key
Player - Player 10 (Light Blue) Releases the Right Arrow key
Player - Player 11 (Dark Green) Releases the Right Arrow key
Conditions
Actions
Set Rotation_Right[(Player number of (Triggering player))] = False

[/trigger]



[trigger="Press Up"]
FORWARDxxPRESSxxGAS
Events
Player - Player 1 (Red) Presses the Up Arrow key
Player - Player 2 (Blue) Presses the Up Arrow key
Player - Player 3 (Teal) Presses the Up Arrow key
Player - Player 4 (Purple) Presses the Up Arrow key
Player - Player 5 (Yellow) Presses the Up Arrow key
Player - Player 6 (Orange) Presses the Up Arrow key
Player - Player 7 (Green) Presses the Up Arrow key
Player - Player 8 (Pink) Presses the Up Arrow key
Player - Player 9 (Gray) Presses the Up Arrow key
Player - Player 10 (Light Blue) Presses the Up Arrow key
Player - Player 11 (Dark Green) Presses the Up Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==moving== --------
Set Ahead_Move[Player_Number_of_Trig_Player] = True
Set Ahead_Decelerate[Player_Number_of_Trig_Player] = False
Animation - Play My_Car[Player_Number_of_Trig_Player]'s walk animation

[/trigger]



[trigger="Release Up"]
FORWARDxxRELEASE
Events
Player - Player 1 (Red) Releases the Up Arrow key
Player - Player 2 (Blue) Releases the Up Arrow key
Player - Player 3 (Teal) Releases the Up Arrow key
Player - Player 4 (Purple) Releases the Up Arrow key
Player - Player 5 (Yellow) Releases the Up Arrow key
Player - Player 6 (Orange) Releases the Up Arrow key
Player - Player 7 (Green) Releases the Up Arrow key
Player - Player 8 (Pink) Releases the Up Arrow key
Player - Player 9 (Gray) Releases the Up Arrow key
Player - Player 10 (Light Blue) Releases the Up Arrow key
Player - Player 11 (Dark Green) Releases the Up Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==moving== --------
Set Ahead_Move[Player_Number_of_Trig_Player] = False
Set Ahead_Decelerate[Player_Number_of_Trig_Player] = True

[/trigger]



[trigger="Press Down"]
BACKWARDSxxPRESSxxBREAK
Events
Player - Player 1 (Red) Presses the Down Arrow key
Player - Player 2 (Blue) Presses the Down Arrow key
Player - Player 3 (Teal) Presses the Down Arrow key
Player - Player 4 (Purple) Presses the Down Arrow key
Player - Player 5 (Yellow) Presses the Down Arrow key
Player - Player 6 (Orange) Presses the Down Arrow key
Player - Player 7 (Green) Presses the Down Arrow key
Player - Player 8 (Pink) Presses the Down Arrow key
Player - Player 9 (Gray) Presses the Down Arrow key
Player - Player 10 (Light Blue) Presses the Down Arrow key
Player - Player 11 (Dark Green) Presses the Down Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==moving== --------
Set Backwards_Move[Player_Number_of_Trig_Player] = True
Set Backwards_Decelerate[Player_Number_of_Trig_Player] = False
Animation - Play My_Car[Player_Number_of_Trig_Player]'s walk animation

[/trigger]



[trigger="Release Down"]
BACKWARDSxxRELEASE
Events
Player - Player 1 (Red) Releases the Down Arrow key
Player - Player 2 (Blue) Releases the Down Arrow key
Player - Player 3 (Teal) Releases the Down Arrow key
Player - Player 4 (Purple) Releases the Down Arrow key
Player - Player 5 (Yellow) Releases the Down Arrow key
Player - Player 6 (Orange) Releases the Down Arrow key
Player - Player 7 (Green) Releases the Down Arrow key
Player - Player 8 (Pink) Releases the Down Arrow key
Player - Player 9 (Gray) Releases the Down Arrow key
Player - Player 10 (Light Blue) Releases the Down Arrow key
Player - Player 11 (Dark Green) Releases the Down Arrow key
Conditions
Actions
Set Player_Number_of_Trig_Player = (Player number of (Triggering player))
-------- ==moving== --------
Set Backwards_Move[Player_Number_of_Trig_Player] = False
Set Backwards_Decelerate[Player_Number_of_Trig_Player] = True

[/trigger]


====================================================
Credits:
Made by: Me and my brother Lightlord24x (from Garena)
Resources:
-Soviet Car by Ket (Hive workshop)
-Honk sound effect from SoundBible.com

Keywords:
movement system,arrow key, arrow, key,camera, 3rd person,third person,first person,spell,acceleration,system,GUI,trigger,car,race,custom,racing system
Contents

Smooth Camera+Arrow Key movement 1.4 (Map)

Reviews
12th Dec 2015 IcemanBo: For long time as NeedsFix. Rejected. 15:38, 5th Jan 2015 Maker: You have memory leaks. Additionally this is just another arrow movement system and it offers nothing new or interesting. You could try to make it more...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: For long time as NeedsFix. Rejected.

15:38, 5th Jan 2015
Maker: You have memory leaks.
Additionally this is just another arrow movement system
and it offers nothing new or interesting.
You could try to make it more original and interesting.
 
Level 3
Joined
Mar 14, 2011
Messages
21
Alright guys, i`ve added a title to it, and posted the triggers, hopefully if there is some bug it will get noticed this way.

I`m kinda new here so, i had no clue how to post here but i figured it out.

Anyway please test my system and give me feedback, i`m curious how you find it to be.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Anything used twice or more should be stored in a variable and the variable should be used.
Example: (Player number of (Triggering player))
Variables are faster and more efficient than multiple function calls.

You should not use waits in spells / systems. They are inaccurate among other things. See my tutorial Things you should know when using triggers / gui. Link is in my sig below.

Never use integer A / B. They are inefficient and slow. Make your own custom integer to do the looping.

Only use And all conditions inside an or condition block.
please read the first ITE to find out the reason.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
Every 0.01 seconds is to fast. You should use every 0.03

You should use a list or player force to make looping more efficient rather than looping through all 11 indexes.

This currently has bugs as you can exit from the camera locking.

This is currently more of a template as it does not allow for configuration.

You should check out my camera system http://www.hiveworkshop.com/forums/spells-569/camera-lock-system-v2-5-0-1-a-239423/. It does tons of more stuff than this one. If you want to add the useability to yours and try to update it it may be approved but it is far from being approved in its current state.
 
Level 3
Joined
Apr 26, 2014
Messages
37
My car stops and don't move for some reason after a few seconds of actual driving. It turns round, but it doesn't move forward or backwards for some reason.
What could it be?
 
Level 3
Joined
Mar 14, 2011
Messages
21
Anything used twice or more should be stored in a variable and the variable should be used.
Example: (Player number of (Triggering player))
Variables are faster and more efficient than multiple function calls.
Alright i will modify this, but now i`m concentrating on bug elimination first, then after no bugs are left i will optimize.
You should not use waits in spells / systems. They are inaccurate among other things. See my tutorial Things you should know when using triggers / gui. Link is in my sig below.
Unless you suggest an alternative, i have no idea what you want me to do, i must have that wait in it, otherwise if you press the LEFT,RIGHT keys and dont hold it for atleast 1 second, it wont steer the car, and it will look choppy.
Never use integer A / B. They are inefficient and slow. Make your own custom integer to do the looping.
Should I use Pick every player... is that faster?

Only use And all conditions inside an or condition block.
I do use it like this, there was 1 case where I didn't, so i fixed that, thanks.

Every 0.01 seconds is to fast. You should use every 0.03
I`ve set it to 0.03 but now it feels choppy, i have to change some setting to the camera to make it look better, but you are right 0.01 with 11 players might cause some lagg.However testing it all by myself it was very smooth.
You should use a list or player force to make looping more efficient rather than looping through all 11 indexes.
So Pick every player... is better than the for loop or not?

This currently has bugs as you can exit from the camera locking.
Please specify i have no idea what you are talking about

This is currently more of a template as it does not allow for configuration.
You should check out my camera system http://www.hiveworkshop.com/forums/spells-569/camera-lock-system-v2-5-0-1-a-239423/. It does tons of more stuff than this one. If you want to add the useability to yours and try to update it it may be approved but it is far from being approved in its current state.
It might get rejected at first but i`m woking on it to be approved later, i really really want to fix this as later i might make a car racing map.

It's nice, man. But the acceleration is too much. Can't you make it move/accelerate with/to normal speed?

Of course you can, in the init trigger you can set the PL_STATS_TOPSPEED[playerindex] array, as you wish to be the top speed, the car will accelerate until it hits the top speed.

Also the PL_STATS_ACCELERATION[1] = 0.25 for player 1 might be smaller. Set it to 0.05 for smaller acceleration.

Remember there are 3 variables that are important, which can be used for car game:

Set PL_STATS_HANDLING[] = steering speed
Set PL_STATS_TOPSPEED[] = max speed (accelerates until it hits this)
Set PL_STATS_ACCELERATION[] = the acceleration increment size (better cars accelerate faster than bad cars)

My car stops and don't move for some reason after a few seconds of actual driving. It turns round, but it doesn't move forward or backwards for some reason.
What could it be?
looks good but... why after a while I can not speed?

I`ve observed that, it is because the acceleration and deceleration is not properly synchronized, so far i can not figure out how to do that, maybe somebody can help me please :grin:
 
Last edited by a moderator:
Level 3
Joined
Mar 14, 2011
Messages
21
Instead of adding the players manually, you can loop from 1 to 12 at map init and add Events to corresponding trigger.

Also why is Player 12 exempted? :eek:

Wait hold on, the Init trigger is not finished, is only for demonstration to test it on player 1. I will work on that on my next version.

Player 12 is exempted because there must be a computer player in a game to be able to play, and even if you somehow with jass or something go around this, i`ve never seen a map where you dont have atleast 1 NPC player, especially for a car game (where i suppose you can use my trigger) you need a tournament NPC player or something like that, Neutral Passive is just not good enough.

----------------------------------------------------------------------

Ok at the moment i`m woking on the spell, wait 30 maybe 45 minutes and i will post the new version where i will definitely correct that movement bug ASAP, i have a very good idea how to synchronize the acceleration/deceleration, i will use the rotation scheme to do it, because there even if you hold the RIGHT/LEFT arrow simultaneously it works perfectly, the same way i will do with UP/DOWN arrows. While the deceleration will be an absolute value always, so that it will always go to 0 speed when substracted, while the BACKWARDS move will be negative speed with a mirror NEGATIVE TOP SPEED at its cap, so that if you push the UP/DOWN simultaneously it will either substract/add a speed to it, and because the Reverse move is slower than the forward acceleration, it will go ahead, but it will slow down the car, as if its only the ACCELERATION pushed, then the car will accelerate at TOP SPEED.

Version 1.1

Changelog:
-Fixed sliding bug (fractional division leftover could cause the car to not stop is fixed)
-Fixed acceleration/deceleration sync, now you can do both at a time and it will add/subtract from the current speed
-Added custom car model and horn effect
-Reworked the triggers and removed unnecesary variables
-Added speedometer, however it might memory leak, but it is not meant to use in the main system, it is just for misc/debug stuff for now, the main system is MOVEMENTSYSTEM folder, everything else is misc or init stuff

I`ve fixed the car stopping/ and or going wild like a boomerang if keys are pressed in bad order, it was a crucial bug so im glad that its fixed, i had to rework the triggers a bit, and it was easy to fix.

Past version used unit facing (Car facing) for forward and (Car Facing-180*) for backwards which caused the bug as if you cant add or subtract speed to different angled variables, so i`m not only using Car facing, but the reverse direction is now using negative speed and negative top speed.So if i decide to work on a speedometer too then i will have to use absolute value of that, but otherwise its perfect now.

On the other hand the camera system is still a bit too crude and choppy but i will work on that, maybe i will use a custom camera system for that, as suggested by deathismyfriend

I will also try to add a collision system, and a car health system if it collides it loses health, maybe some nice animations for the car to get on fire if it collides with something.
 
Last edited by a moderator:
Level 29
Joined
Oct 24, 2012
Messages
6,543
Using an integer loop is faster than a player force loop. But you need to use an indexing type when players leave they need to be removed. When the game starts only the playing players should be put into the player force.
Player force will be better and easier to use here.

There were many cases where you used an and all condition block inside the ITE.

You lock you camera to a unit to prevent a player from moving the camera. This locking can be stopped by the keyboard (I forget the button/s).

About waits use timers / triggers with a time elapsed event to get rid of the use of the waits. Look at my tutorial for more information. Things You Should Know When Using Triggers / GUI
 
Level 3
Joined
Mar 14, 2011
Messages
21
Using an integer loop is faster than a player force loop. But you need to use an indexing type when players leave they need to be removed. When the game starts only the playing players should be put into the player force.
Player force will be better and easier to use here.
What if i leave the integer loop but right at the beginning i test if the player is playing and or is a human player.
Will that be efficient and fast, faster than player loop?
There were many cases where you used an and all condition block inside the ITE.
I`m sure i fixed them all

You lock you camera to a unit to prevent a player from moving the camera. This locking can be stopped by the keyboard (I forget the button/s).
I will look into this
About waits use timers / triggers with a time elapsed event to get rid of the use of the waits. Look at my tutorial for more information. Things You Should Know When Using Triggers / GUI
Please give link, the only thing i found there is that you say that a 0.75 sec wait is more efficient, yet i have 0.1 second and the timing itself is not that important, its only for rotation effect if it delays 0.1-0.3 then its ok, the player will experience a bit of rotation sliding but i think its acceptable at that level.
 
Level 3
Joined
Mar 14, 2011
Messages
21
Putting players in a permanent player force will be faster than always searching through a loop each iteration.

The link is in my sig.

Also post triggers in map description.

Alright i will do that, and test for player if its human, or of its in game in case of somebody leaves to be faster.

However, i will disable these tests, since until i finish this system i would like to experience how it feels if all 11 are in.Because if i test it in 1st person alone, i would only experience how it feels with 1 person playing, but i want to experience how it feels with 11 person playing, to see if its lagging too much or what.

Anyway i really appreciate your feedback and help man, please continue to feedback, i need it.
 
Level 13
Joined
Jul 16, 2012
Messages
679


• The name of the trigger must be read properly. (Optional)
Ex: SP Int, SP Loop, etc

• 0.01 using periodic time , some computers will become laggy . so use 0.03 instead or above.

• Do not use Integer A or B , use an integer variable instead

• Dont use Wait

• You can also do it like this
  • Example
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer SP_TempInt) from 1 to 11, do (Actions)
        • Loop - Actions
          • Trigger - Add to LEFTxxPRESS <gen> the event (Player - (Player(SP_TempInt)) Presses the Left Arrow key)
          • Trigger - Add to LEFTxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Left Arrow key)
          • Trigger - Add to RIGHTxxPRESS <gen> the event (Player - (Player(SP_TempInt)) Presses the Right Arrow key)
          • Trigger - Add to RIGHTxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Right Arrow key)
          • Trigger - Add to FORWARDxxPRESSxxGAS <gen> the event (Player - (Player(SP_TempInt)) Presses the Up Arrow key)
          • Trigger - Add to FORWARDxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Up Arrow key)
          • Trigger - Add to BACKWARDSxxPRESSxxBREAK <gen> the event (Player - (Player(SP_TempInt)) Presses the Down Arrow key)
          • Trigger - Add to BACKWARDSxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Down Arrow key)
      • Custom script: call DestroyTrigger( GetTriggeringTrigger())
 
Level 3
Joined
Mar 14, 2011
Messages
21


• The name of the trigger must be read properly. (Optional)
Ex: SP Int, SP Loop, etc

• 0.01 using periodic time , some computers will become laggy . so use 0.03 instead or above.

• Do not use Integer A or B , use an integer variable instead

• Dont use Wait

• You can also do it like this
  • Example
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer SP_TempInt) from 1 to 11, do (Actions)
        • Loop - Actions
          • Trigger - Add to LEFTxxPRESS <gen> the event (Player - (Player(SP_TempInt)) Presses the Left Arrow key)
          • Trigger - Add to LEFTxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Left Arrow key)
          • Trigger - Add to RIGHTxxPRESS <gen> the event (Player - (Player(SP_TempInt)) Presses the Right Arrow key)
          • Trigger - Add to RIGHTxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Right Arrow key)
          • Trigger - Add to FORWARDxxPRESSxxGAS <gen> the event (Player - (Player(SP_TempInt)) Presses the Up Arrow key)
          • Trigger - Add to FORWARDxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Up Arrow key)
          • Trigger - Add to BACKWARDSxxPRESSxxBREAK <gen> the event (Player - (Player(SP_TempInt)) Presses the Down Arrow key)
          • Trigger - Add to BACKWARDSxxRELEASE <gen> the event (Player - (Player(SP_TempInt)) Releases the Down Arrow key)
      • Custom script: call DestroyTrigger( GetTriggeringTrigger())

Note that i`ve updated the map, fixed many stuff so please review it again.

Also i`m using now Pick every player ... , because deathismyfriend told that its faster than the integer, (not that it changes anything in the framepersecond, but probably its better with more players)

  • Can you prove that your trigger inside the integer is faster than the one mentioned by deathismyfriend?
    If not then i will use the Pick every player ...
  • Also if i were to use 0.03 then the camera gets too choppy i will test them map this afternoon with more players but i dont guarantee anything.
  • Also give me an alternative to wait, all of you said that i should not use it, but none of you gave any alternative to it... :vw_wtf:


Putting players in a permanent player force will be faster than always searching through a loop each iteration.

The link is in my sig.

Also post triggers in map description.

Alright i`ve updated the map fixed many stuff, and did as you suggested, now i got a player group and a variable for player number of picked player and also its memory leak free.

However i didnt experienced any change between this method and the for loop integer method, the FPS is the same with both methods, are you sure this one is faster?? :ogre_haosis:
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
However i didnt experienced any change between this method and the for loop integer method, the FPS is the same with both methods, are you sure this one is faster?? :ogre_haosis:

Yes it is definitely faster as it will only loop through 1 person if only one person is playing rather than always running through all 12 players.

Also As I have said put this.
  • Set GROUP_PLAYINGPLAYERS = (All players controlled by a User player)
into a map init trigger. Never destroy this group never set it to anything else.

You also need to only add players if they are a player slot and that they are playing. Then you need another trigger to remove the players that leave.

Indexing Function. this is the most important in making spell

so that you can make alternative wait

I also said that way is better.
 
System seems cool. I wanted to read the code, but the variable names are not really readable. Could you improve it?

First, if you use capitals-only names, you only should use it for constant variables. (if you never change it's value)
The namings don't have a proper structure. You should define it for and by the system, for example for GUI I prefer something like: Prefix + underscope + VariableName.
 
Level 3
Joined
Mar 14, 2011
Messages
21
Indexing Function. this is the most important in making spell

so that you can make alternative wait
I have no idea what that is can you please explain more detailed not just in hint words, thanks :grin:

System seems cool. I wanted to read the code, but the variable names are not really readable. Could you improve it?

First, if you use capitals-only names, you only should use it for constant variables. (if you never change it's value)
The namings don't have a proper structure. You should define it for and by the system, for example for GUI I prefer something like: Prefix + underscope + VariableName.

Allright i will do that in the next update, i thought its easy to read as i named it first the role of the variables + then a custom name.

Yes it is definitely faster as it will only loop through 1 person if only one person is playing rather than always running through all 12 players.

Also As I have said put this.
  • Set GROUP_PLAYINGPLAYERS = (All players controlled by a User player)
into a map init trigger. Never destroy this group never set it to anything else.

You also need to only add players if they are a player slot and that they are playing. Then you need another trigger to remove the players that leave.

I also said that way is better.

Alright its done 1.3 version, corrected that, its logical btw to only go through once since no PC players will be added.Thanks for this observation.

Btw can anyone please detailed explain how to replace the wait, because now i`m really confused, please help with that.Thanks!
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
I have no idea what that is can you please explain more detailed not just in hint words, thanks :grin:

You should stick with a player group as it will be slightly faster in most cases.

Btw can anyone please detailed explain how to replace the wait, because now i`m really confused, please help with that.Thanks!

Look at my tutorial Things you should know when using triggers / gui. Link is in my sig. The chapter on how to index will show you how to index a spell. It is the same way for the above system.


You do this in your init.
  • ((Picked player) slot status) Equal to Is playing
You can't use a player loop for checking players on init. Change trigger to 0.00 time elapsed.
You also need this
  • ((Picked player) controller) Equal to User
The above line is needed because even computer players are considered as playing. These two conditions will only add users that are playing. It will not add computer players.
You should also use a player variable to store picked player as it will be used more than once.
 
Level 3
Joined
Mar 14, 2011
Messages
21
You should stick with a player group as it will be slightly faster in most cases.



Look at my tutorial Things you should know when using triggers / gui. Link is in my sig. The chapter on how to index will show you how to index a spell. It is the same way for the above system.


You do this in your init.
  • ((Picked player) slot status) Equal to Is playing
You can't use a player loop for checking players on init. Change trigger to 0.00 time elapsed.
You also need this
  • ((Picked player) controller) Equal to User
The above line is needed because even computer players are considered as playing. These two conditions will only add users that are playing. It will not add computer players.
You should also use a player variable to store picked player as it will be used more than once.

Whats wrong with:
  • Set GROUP_PLAYINGPLAYERS = (All players controlled by a User player)
Doesnt this substitute for
  • ((Picked player) controller) Equal to User
I mean there will be only 1 computer player , player12 which will remain constant, there will be no new computer players added inside the game or anything like that.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Whats wrong with:
  • Set GROUP_PLAYINGPLAYERS = (All players controlled by a User player)
Doesnt this substitute for
  • ((Picked player) controller) Equal to User

Yes it substitutes for that. But you also need to check if the player is currently playing. That will add players 1 to 11 even if players 2 through 6 are not playing.
You do this in your init.
  • ((Picked player) slot status) Equal to Is playing
You can't use a player loop for checking players on init. Change trigger to 0.00 time elapsed.
You also need this
  • ((Picked player) controller) Equal to User
The above line is needed because even computer players are considered as playing. These two conditions will only add users that are playing. It will not add computer players.

You can then remove the ITE in your player group since only players that are playing will be in there.
And as said above the map init event needs to be changed to 0.00 time elapsed.

I mean there will be only 1 computer player , player12 which will remain constant, there will be no new computer players added inside the game or anything like that.

A system uploaded to here needs to be able to be used for maps that use all 12 players. Also as I said above it needs to be changed because. This system needs to be expanded to allow for all 12 players.
 
Level 3
Joined
Mar 14, 2011
Messages
21
Yes it substitutes for that. But you also need to check if the player is currently playing. That will add players 1 to 11 even if players 2 through 6 are not playing.


You can then remove the ITE in your player group since only players that are playing will be in there.
And as said above the map init event needs to be changed to 0.00 time elapsed.



A system uploaded to here needs to be able to be used for maps that use all 12 players. Also as I said above it needs to be changed because. This system needs to be expanded to allow for all 12 players.

Ok i just updated my system now, so come back and check the changes please.

I do check the players that are curretly playing, i dont know why you said i dont.
Right at the beginning of the new init (elapsed 0.00 seconds)
  • Set Group_Playing_Players = (All players controlled by a User player)
This line completely replaces the
  • ((Picked player) controller) Equal to User
because i only test it once at the beginning of the map elapsed 0.00 seconds, instead of testing it at every 0.01 seconds will just slow down the map, because either way there will be no more PC players added during the map.

As for

  • ((Picked player) slot status) Equal to Is playing
That is also tested at init, and also at every 0.01 second it case there is a leaver player to not loop through that.

I also did as you requested, moved the picked player and triggering player into a variables to be more faster.

Also i resolved the wait stuff with something very simple yet effective, as i didnt understood how that indexing stuff worked.

So please review my code again, as it seems that you didnt saw the new updates.
 
Top