Hello,
I have the following problem:
I'm trying to create a ball with physics. When it rolls down a ramp it accelerates, when it rolls over a cliff it falls down etc. Basically everything a real ball would do.
I have no idea how to do this and I would really appreciate it if anyone could tell me if this is even possible / how to get it working.
I would start with going into the Data Editor and turning on for the ball "Ignore Terrain Height", for starters.
Change the Ball unit's acceleration to As High as it can go, Deceleration also as High as it can go.
In the Trigger Editor, create these Global variables:
XYAngle<real>XYSpeed<real>ZSpeed<real>
Make some Constants that you will use for Decelerating the ball, to make sure that it does not just roll forever everywhere, and actually make it seem real.
Is there a way to do the same for a unit, when it goes down a ramp it accelerates, when it goes up a ramp it deceallarates, but keep the basic movement speed the same? like, a zergling that changes movementspeed based on height difference?
Melee Initialization
Events
Game - Map initialization
Local Variables
BallZ = 0.0 <Real>
Conditions
Actions
General - Repeat (Actions) forever
Actions
Variable - Set XYSpeed = (XYSpeed - Const_XYDeceleration)
Variable - Set ZSpeed = (ZSpeed - Const_ZGravity)
Unit - Order Hellion [75.00, 85.50] to ( Move targeting ((Position of Hellion [75.00, 85.50]) offset by XYSpeed towards XYAngle degrees)) (Replace Existing Orders)
Unit - Change Hellion [75.00, 85.50] height to (BallZ + ZSpeed) over 0.625 seconds
Variable - Set BallZ = (Hellion [75.00, 85.50] Height (Current))
Unit - Set Hellion [75.00, 85.50] Movement Speed to XYSpeed
Melee - Set melee starting resources for all players
Melee - Create melee starting units for all players
Melee - Start the melee AI for all computer players
Melee - Set default melee options for all players
I keep getting an error, it sais the error is in line 53... how can I fix this
Do you mean like when the Zergling moves down/up it continuously accelerates/decelerates and as soon as it stops it reaches it's Original movement speed? If so, i think this trigger might help you:
periodic
Events
Game - Map initialization
Local Variables
Conditions
Actions
General - While (Conditions) are true, do (Actions)
Conditions
(Owner of Zergling [62.11, 64.09]) == 1
Actions
Variable - Set Z Zergling = (Ground height at (Position of Zergling [62.11, 64.09]))
General - Wait 0.1 Game Time seconds
Variable - Set Z Zergling 2 = (Ground height at (Position of Zergling [62.11, 64.09]))
Variable - Set difference = (Z Zergling 2 - Z Zergling)
General - If (Conditions) then do (Actions) else do (Actions)
If
difference > 0.0
Then
Unit - Add 1 deceleration to Zergling [62.11, 64.09] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference < 0.0
Then
Unit - Add 1 acceleration to Zergling [62.11, 64.09] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference == 0.0
Then
Unit - Remove 1000 acceleration from Zergling [62.11, 64.09]
Unit - Remove 1000 deceleration from Zergling [62.11, 64.09]
Else
I set 3 variables for this Trigger:
difference = 0.0 <Real>
Z Zergling = 0.0 <Real>
Z Zergling 2 = 0.0 <Real>
and 2 behaviors (acceleration and deceleration) which both have a max stack count of 1000 and the duration of both is 5 seconds.
The acceleraton behavior adds 0.05 movement speed to the unit and the deceleration behavior adds -0.05.
I've tested this trigger and it works just as intended.
Also,in terms of text formation, how can i make a trigger look like the one from gerudobombshell?
I am trying o do the exact thing you are doing, just not with a ball, but with a unit, that has a normal movement speed if it is on a normal plane, but can also fall down cliffs
I mean, it has friction, but it doesn't go lower than the speed of, let's say 2 (Edit: exept when goin uphill, then the minimum is , let's say 1.5). also, I tried you code and it either does nothign or everything at once, where is my mistake?
I am trying to make a race map, but there will be slopes that pull you down, or cliffs that if you fall down you have to get back up again.
Edit 2: Formatting errors
Edit 3: you do the code line text by typing " < < code > >" no spaces, no qutations, " < < / code > > " to end code, no space no quotation
In your trigger, the variables Z Zergling and Z Zergling 2 are both 0 because the height of the Zergling (relative to the ground) is 0. This took me quite a while too to figure out.
edit: Thank you for the << code>> info!
No you wouldn't.
There's quite a few ways you could do this, but a unit group may be the easiest.
Add all of your physics units into a global unit group.
Make your global variables into arrays with a decent size. The max amount of possible zerglings plus a few is a good number.
Then you need to create a way to organize your zerglings so that each zergling is appropriately marked to a specific number.
This number will be the number that corresponds to its position in the variable arrays you just made.
I suggest using the unit's custom values. Make each one's custom value for 0, into this unique specific number.
You can do this by using the Action - Set Unit Custom Value.
Now you need to rewrite that previous trigger so that it cycles through the unit group. Unit Group - Pick every unit in unit group and do actions.
Just replace any reference to that original zergling with a "Picked Unit" reference.
You'll also need a system for catalogueing the new zerglings if you plan to remove/add zerglings throughout the game.
Wouldn't it be enough to add all units into a Unit Group,and then rewrite the trigger so it cycles through the Unit Group?
Why do you need this part?
Quote:
Then you need to create a way to organize your zerglings so that each zergling is appropriately marked to a specific number.
This number will be the number that corresponds to its position in the variable arrays you just made.
I suggest using the unit's custom values. Make each one's custom value for 0, into this unique specific number.
You can do this by using the Action - Set Unit Custom Value.
Okay, I've tried to get AmidaZ and Gerus variant to work
MeleeInitializationEventsGame-MapinitializationLocalVariablesMarineZ=0.0<Real>ConditionsActionsGeneral-Repeat(Actions)foreverActionsUnit-SetMarine[60.47,63.60] Movement Speed to (XYSpeed / 16.0)
Variable - Set MarineZ = (Marine [60.47,63.60] Height (Current))
Unit - Order Marine [60.47,63.60] to ( Move targeting ((Position of Marine [60.47,63.60]) offset by XYSpeed towards XYAngle degrees)) (Replace Existing Orders)
Unit - Change Marine [60.47,63.60] height to (MarineZ + ZSpeed) over 0.625 seconds
Variable - Set XYSpeed = (XYSpeed - Const_XYDeceleration)
Variable - Set MarineZ = (ZSpeed - Const_ZGravity)
General - Wait 0.625 Game Time seconds
General - While (Conditions) are true, do (Actions)
Conditions
(Owner of Zergling [61.51,63.65]) == 1
Actions
Variable - Set Z Zergling = (Ground height at (Position of Zergling [61.51,63.65]))
General - Wait 0.1 Game Time seconds
Variable - Set Z Zergling 2 = (Ground height at (Position of Zergling [61.51,63.65]))
Variable - Set difference = (Z Zergling 2 - Z Zergling)
General - If (Conditions) then do (Actions) else do (Actions)
If
difference < 0.0ThenUnit-Add1AcceleratetoZergling[61.51,63.65]fromplayer1ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)Ifdifference> 0.0
Then
Unit - Add 1 Decelerate to Zergling [61.51,63.65] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference == 0.0
Then
Unit - Remove 1000 Accelerate from Zergling [61.51,63.65]
Unit - Remove 1000 Decelerate from Zergling [61.51,63.65]
Else
Melee - Set melee starting resources for all players
Melee - Create melee starting units for all players
Melee - Start the melee AI for all computer players
Melee - Set default melee options for all players
this is my code, the zerfling works 100% of the time, the marine, however, "can't handle that command" when told to move, if it ignores terrain hight the same thing happens and if I set the acceleration or decceleration to anything, really. I tried placing the unit on a slope to see if that had an effect, nope, the marine can't move, it van't, if I remove the triggers involving the marine, It can, where is my mistake?
Okay, I've tried to get AmidaZ and Jux variant to work
MeleeInitializationEventsGame-MapinitializationLocalVariablesMarineZ=0.0<Real>ConditionsActionsGeneral-Repeat(Actions)foreverActionsUnit-SetMarine[60.47,63.60] Movement Speed to (XYSpeed / 16.0)
Variable - Set MarineZ = (Marine [60.47,63.60] Height (Current))
Unit - Order Marine [60.47,63.60] to ( Move targeting ((Position of Marine [60.47,63.60]) offset by XYSpeed towards XYAngle degrees)) (Replace Existing Orders)
Unit - Change Marine [60.47,63.60] height to (MarineZ + ZSpeed) over 0.625 seconds
Variable - Set XYSpeed = (XYSpeed - Const_XYDeceleration)
Variable - Set MarineZ = (ZSpeed - Const_ZGravity)
General - Wait 0.625 Game Time seconds
General - While (Conditions) are true, do (Actions)
Conditions
(Owner of Zergling [61.51,63.65]) == 1
Actions
Variable - Set Z Zergling = (Ground height at (Position of Zergling [61.51,63.65]))
General - Wait 0.1 Game Time seconds
Variable - Set Z Zergling 2 = (Ground height at (Position of Zergling [61.51,63.65]))
Variable - Set difference = (Z Zergling 2 - Z Zergling)
General - If (Conditions) then do (Actions) else do (Actions)
If
difference < 0.0ThenUnit-Add1AcceleratetoZergling[61.51,63.65]fromplayer1ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)Ifdifference> 0.0
Then
Unit - Add 1 Decelerate to Zergling [61.51,63.65] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference == 0.0
Then
Unit - Remove 1000 Accelerate from Zergling [61.51,63.65]
Unit - Remove 1000 Decelerate from Zergling [61.51,63.65]
Else
Melee - Set melee starting resources for all players
Melee - Create melee starting units for all players
Melee - Start the melee AI for all computer players
Melee - Set default melee options for all players
this is my code, the zerfling works 100% of the time, the marine, however, "can't handle that command" when told to move, if it ignores terrain hight the same thing happens and if I set the acceleration or decceleration to anything, really. I tried placing the unit on a slope to see if that had an effect, nope, the marine can't move, it van't, if I remove the triggers involving the marine, It can, where is my mistake?
You could try putting a Pick Every Unit in Unit Group action, then replacing every reference of zergling with the Picked Unit.
I'm not sure what you're trying with the marine in this?
But I'm having a problem with this. The trigger itself works, but it is not picking every unit at once. As far as I've seen through testing, it picks Zergling 1 from the zerglinggroup and does [Actions], after that picks Zergling 2 and does [Actions] etc. What do I need to change so that the trigger picks every Unit at once and does actions?
I hope you understand my problem.
Hello, I have the following problem: I'm trying to create a ball with physics. When it rolls down a ramp it accelerates, when it rolls over a cliff it falls down etc. Basically everything a real ball would do. I have no idea how to do this and I would really appreciate it if anyone could tell me if this is even possible / how to get it working.
Absolutely is possible.
I would start with going into the Data Editor and turning on for the ball "Ignore Terrain Height", for starters. Change the Ball unit's acceleration to As High as it can go, Deceleration also as High as it can go.
In the Trigger Editor, create these Global variables:
Make some Constants that you will use for Decelerating the ball, to make sure that it does not just roll forever everywhere, and actually make it seem real.
Then, create an action that looks something like this:
That will get you started I hope, Good luck! I might goof around with this idea later if I have time.
@gerudobombshell: Go
Is there a way to do the same for a unit, when it goes down a ramp it accelerates, when it goes up a ramp it deceallarates, but keep the basic movement speed the same? like, a zergling that changes movementspeed based on height difference?
@gerudobombshell: Go
Melee Initialization Events Game - Map initialization Local Variables BallZ = 0.0 <Real> Conditions Actions General - Repeat (Actions) forever Actions Variable - Set XYSpeed = (XYSpeed - Const_XYDeceleration) Variable - Set ZSpeed = (ZSpeed - Const_ZGravity) Unit - Order Hellion [75.00, 85.50] to ( Move targeting ((Position of Hellion [75.00, 85.50]) offset by XYSpeed towards XYAngle degrees)) (Replace Existing Orders) Unit - Change Hellion [75.00, 85.50] height to (BallZ + ZSpeed) over 0.625 seconds Variable - Set BallZ = (Hellion [75.00, 85.50] Height (Current)) Unit - Set Hellion [75.00, 85.50] Movement Speed to XYSpeed Melee - Set melee starting resources for all players Melee - Create melee starting units for all players Melee - Start the melee AI for all computer players Melee - Set default melee options for all players
I keep getting an error, it sais the error is in line 53... how can I fix this
@gerudobombshell
I'm having trouble understanding what your trigger does. Could you please explain it a little?
* Set **Ball** Property **Movement Speed** to (**XYSpeed** / **16**)
Why divide by 16?
* Unit Issue Order (Ball to (Move Targeting (Point With Offset Polar **(Position Of (Ball), XYSpeed, XYAngle)))
**
I don't understand the offset.
* Change Unit Height (Ball, BallZ + ZSpeed, 0.625)
I can't make sense of these 4 variables.
Thank you in advance
@gerudobombshell
Do you mean like when the Zergling moves down/up it continuously accelerates/decelerates and as soon as it stops it reaches it's Original movement speed? If so, i think this trigger might help you:
periodic
Events
Game - Map initialization
Local Variables
Conditions
Actions
General - While (Conditions) are true, do (Actions)
Conditions
(Owner of Zergling [62.11, 64.09]) == 1
Actions
Variable - Set Z Zergling = (Ground height at (Position of Zergling [62.11, 64.09]))
General - Wait 0.1 Game Time seconds
Variable - Set Z Zergling 2 = (Ground height at (Position of Zergling [62.11, 64.09]))
Variable - Set difference = (Z Zergling 2 - Z Zergling)
General - If (Conditions) then do (Actions) else do (Actions)
If
difference > 0.0
Then
Unit - Add 1 deceleration to Zergling [62.11, 64.09] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference < 0.0
Then
Unit - Add 1 acceleration to Zergling [62.11, 64.09] from player 1
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
difference == 0.0
Then
Unit - Remove 1000 acceleration from Zergling [62.11, 64.09]
Unit - Remove 1000 deceleration from Zergling [62.11, 64.09]
Else
I set 3 variables for this Trigger:
difference = 0.0 <Real>
Z Zergling = 0.0 <Real>
Z Zergling 2 = 0.0 <Real>
and 2 behaviors (acceleration and deceleration) which both have a max stack count of 1000 and the duration of both is 5 seconds.
The acceleraton behavior adds 0.05 movement speed to the unit and the deceleration behavior adds -0.05.
I've tested this trigger and it works just as intended.
Also,in terms of text formation, how can i make a trigger look like the one from gerudobombshell?
@AmidaZ: Go
I am trying o do the exact thing you are doing, just not with a ball, but with a unit, that has a normal movement speed if it is on a normal plane, but can also fall down cliffs
@PillowFort: Go
I don't know how, but I ike yours better
@AmidaZ: Go
I mean, it has friction, but it doesn't go lower than the speed of, let's say 2 (Edit: exept when goin uphill, then the minimum is , let's say 1.5). also, I tried you code and it either does nothign or everything at once, where is my mistake?
I am trying to make a race map, but there will be slopes that pull you down, or cliffs that if you fall down you have to get back up again.
Edit 2: Formatting errors Edit 3: you do the code line text by typing " < < code > >" no spaces, no qutations, " < < / code > > " to end code, no space no quotation
You made the same misstake as me:
You took the element "Height of Unit":
But you need to take "Height at point"(not Height of Point!):
In your trigger, the variables Z Zergling and Z Zergling 2 are both 0 because the height of the Zergling (relative to the ground) is 0. This took me quite a while too to figure out. edit: Thank you for the << code>> info!
@AmidaZ: Go
ohh,guess thats why I'm the noob, Thanks.
@AmidaZ: Go
is there a way to not apply this to my zergling but to every zegling?
@PillowFort: Go
Don't take me for granted on that one, but I think you'd have to create one trigger for each unit. Somebody correct me here please if I'm wrong.
@AmidaZ: Go
No you wouldn't.
There's quite a few ways you could do this, but a unit group may be the easiest.
Add all of your physics units into a global unit group.
Make your global variables into arrays with a decent size. The max amount of possible zerglings plus a few is a good number.
Then you need to create a way to organize your zerglings so that each zergling is appropriately marked to a specific number.
This number will be the number that corresponds to its position in the variable arrays you just made.
I suggest using the unit's custom values. Make each one's custom value for 0, into this unique specific number.
You can do this by using the Action - Set Unit Custom Value.
Now you need to rewrite that previous trigger so that it cycles through the unit group. Unit Group - Pick every unit in unit group and do actions.
Just replace any reference to that original zergling with a "Picked Unit" reference.
You'll also need a system for catalogueing the new zerglings if you plan to remove/add zerglings throughout the game.
This was a little vague, but I hope it helped.
@Juxtapozition: Go
would it be easier to apply to every unit instead of every zergling?
@Juxtapozition: Go
Wouldn't it be enough to add all units into a Unit Group,and then rewrite the trigger so it cycles through the Unit Group?
Why do you need this part?
@AmidaZ: Go
Okay, I've tried to get AmidaZ and Gerus variant to work
this is my code, the zerfling works 100% of the time, the marine, however, "can't handle that command" when told to move, if it ignores terrain hight the same thing happens and if I set the acceleration or decceleration to anything, really. I tried placing the unit on a slope to see if that had an effect, nope, the marine can't move, it van't, if I remove the triggers involving the marine, It can, where is my mistake?
@AmidaZ: Go
Okay, I've tried to get AmidaZ and Jux variant to work
this is my code, the zerfling works 100% of the time, the marine, however, "can't handle that command" when told to move, if it ignores terrain hight the same thing happens and if I set the acceleration or decceleration to anything, really. I tried placing the unit on a slope to see if that had an effect, nope, the marine can't move, it van't, if I remove the triggers involving the marine, It can, where is my mistake?
@AmidaZ: Go
It might not be necessary especially if you're not adding or removing zerglings to/from this group.
@PillowFort: Go
You could try putting a Pick Every Unit in Unit Group action, then replacing every reference of zergling with the Picked Unit.
I'm not sure what you're trying with the marine in this?
@Juxtapozition: Go
Gerus code, the physics ball, I tried to do exactly that.
@Juxtapozition: Go
OK so I've tried it with the unit group:
But I'm having a problem with this. The trigger itself works, but it is not picking every unit at once. As far as I've seen through testing, it picks Zergling 1 from the zerglinggroup and does [Actions], after that picks Zergling 2 and does [Actions] etc. What do I need to change so that the trigger picks every Unit at once and does actions?
I hope you understand my problem.
@PillowFort: Go
He didn't create the second post, that was gerudobombshell.