• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Syncing Unit Movements

Status
Not open for further replies.
Level 6
Joined
Aug 24, 2006
Messages
253
Okay, so I've seen maps where units mirror each others movements and it works pretty smoothly so I think I can get this to work as well.

I want to make a map where the player can control the turret of a vehicle, like a tank, while it drives around on a set track. So I obviously want the turret to be able to turn like it does in reality, which obviously requires free rotation.

I can't really think of a way to do this, so I'm hoping someone can help.

I want to make the vehicle two separate models, one being the body and the other the turret, then sync the movement of the two, allowing the players to control the turret of the vehicle. Is there a way to do this?

Also, the players have to order the vehicles, it doesn't appear at the start, so it needs to apply to all vehicles of that type made if that's possible.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
Create two units with same movement speed, give the "body" unit locust ability and turret rotation speed 0 (i don't know exactly how this attribute is called, it's in movement, and usually between 0.1 and 3). Then just 1) order the base unit whenever turret is ordered and 2) move turret to position of body. Like this:
  • Event
    • Unit - A unit is issued order targeting a point
  • Conditions
    • Unit-Type of (Ordered unit) equals to "turret unit"
  • Actions
    • Unit - order "body unit" to "move to" to (target of issued order)
  • Event
    • Time - every 0.05 seconds of game time
  • Actions
    • set point = Position of "body unit"
    • Custom script: call SetUnitX( udg_"turret unit", GetLocationX( udg_point) )
    • Custom script: call SetUnitY( udg_"turret unit", GetLocationY( udg_point) )
    • call RemoveLocation( udg_point )
 
Level 6
Joined
Aug 24, 2006
Messages
253
Well how would I make it so that it applies that trigger to every vehicle that is ordered?

Nevermind I didn't pay attention very well.

Thanks man.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
Nevermind I didn't pay attention very well.
And that's what you get for trying to help....

For example, I would save each player's body and turret units to variables (Player_body and Player_turret) when you create them. Then just modify the triggers:
  • Event
  • Unit - A unit is issued order targeting a point
  • Conditions
    • Unit-Type of (Ordered unit) equals to "turret unit"
  • Actions
    • Unit - order Player_body[Player number of (Owner of (Ordered unit))] to "move to" to (target of issued order)
  • Event
    • Time - every 0.05 seconds of game time
  • Actions
    • For each (Integer A) 1 to 12
      • set point = Position of Player_body[Integer A]
      • Custom script: call SetUnitX( udg_Player_turret[GetForLoopIndexA()], GetLocationX( udg_point) )
      • Custom script: call SetUnitY( udg_Player_turret[GetForLoopIndexA()], GetLocationY( udg_point) )
      • Custom Script: call RemoveLocation( udg_point )
 
Level 6
Joined
Aug 24, 2006
Messages
253
Sorry....

Alright, I think that'll work. I'll go work on it tonight whenever I make my way home.

Thanks a lot, man.
 
Status
Not open for further replies.
Top