1movehandler
Events
Timer - Every 0.1 seconds of Game Time
Local Variables
Conditions
Actions
Point - Move point1 To (Position of P1Unit)
Point - Move point2 To ((Position of P1Unit) offset by (P1UnitSpeed * 0.1) towards MovementAngle degrees)
Variable - Set 1currzheight = (Ground height at (Position of P1Unit))
Variable - Set magnitude = (1currzheight - 1prevzheight)
Variable - Set 1prevzheight = 1currzheight
Variable - Set 1heightofjump = (1currzheight + magnitude)
Unit - Change P1Unit height to (1heightofjump - (Ground height at point1)) over 0.1 seconds
Debug - Display (Text(1heightofjump) with 6 decimal places) as debug output using Type 1, and Do display it in the game window
Okay, this is just a simple physics script that should determine the magnitude based on the previous height calculated and the current height. it doesn't have gravity in yet so a unit should just start floating up indefinitely when the magnitude becomes positive...
however in game the unit jumps up a small ammount and then goes back to the ground like there is gravity... this is pissing me off.
Point - Move point2 To ((Position of P1Unit) offset by (P1UnitSpeed * 0.1) towards MovementAngle degrees)
Variable - Set 1currzheight = (Ground height at (Position of P1Unit))
Variable - Set magnitude = (1currzheight - 1prevzheight)
Variable - Set 1prevzheight = 1currzheight
Variable - Set 1heightofjump = (1currzheight + magnitude)
Unit - Change P1Unit height to (1heightofjump - (Ground height at point1)) over 0.1 seconds Debug - Display (Text(1heightofjump) with 6 decimal places) as debug output using Type 1, and Do display it in the game window
That should make it easier to read. Now I'm going to actually figure out what it means.
Point - Move point2 To ((Position of P1Unit) offset by (P1UnitSpeed * 0.1) towards MovementAngle degrees)
Variable - Set 1currzheight = (Ground height at (Position of P1Unit))
Variable - Set magnitude = (1currzheight - 1prevzheight)
Variable - Set 1prevzheight = 1currzheight
Variable - Set 1heightofjump = (1currzheight + magnitude)
Unit - Change P1Unit height to (1heightofjump - (Ground height at point1)) over 0.1 seconds Debug - Display (Text(1heightofjump) with 6 decimal places) as debug output using Type 1, and Do display it in the game window
That should make it easier to read. Now I'm going to actually figure out what it means.
After the trigger runs a first time, 1currzheight and 1prevzheight are both equal to (Ground height at (Position of P1Unit), and they never change from this value.
The second time the trigger runs, magnitude is set to 0, and it never changes from this value.
Which means that 1heightofjump is now equal to (Ground height at (Position of P1Unit)
Which means that (1heightofjump - (Ground height at point1)) is equal to zero, which means after the first time, every time the trigger runs, the units height will be set to zero.
In this kind of situation, it's useful to print out all of the variables as a debug message. If you'd done that, the problem would have been fairly obvious.
I think that setting 1currzheight to the unit's height (rather than the ground height) will make it work how you intended, but I'm not really sure.
1movehandler
Events
Timer - Every 0.1 seconds of Game Time
Local Variables
Conditions
Actions
Point - Move point1 To (Position of P1Unit)
Point - Move point2 To ((Position of P1Unit) offset by (P1UnitSpeed * 0.1) towards MovementAngle degrees)
Variable - Set 1currzheight = (Ground height at (Position of P1Unit))
Variable - Set magnitude = (1currzheight - 1prevzheight)
Variable - Set 1prevzheight = 1currzheight
Variable - Set 1heightofjump = (1currzheight + magnitude)
Unit - Change P1Unit height to (1heightofjump - (Ground height at point1)) over 0.1 seconds
Debug - Display (Text(1heightofjump) with 6 decimal places) as debug output using Type 1, and Do display it in the game window
Okay, this is just a simple physics script that should determine the magnitude based on the previous height calculated and the current height. it doesn't have gravity in yet so a unit should just start floating up indefinitely when the magnitude becomes positive...
however in game the unit jumps up a small ammount and then goes back to the ground like there is gravity... this is pissing me off.
can you guys spot anything thats off?
1movehandler
Events
Timer - Every 0.1 seconds of Game Time
Local Variables
Conditions
Actions
Point - Move point1 To (Position of P1Unit)
Point - Move point2 To ((Position of P1Unit) offset by (P1UnitSpeed * 0.1) towards MovementAngle degrees)
Variable - Set 1currzheight = (Ground height at (Position of P1Unit))
Variable - Set magnitude = (1currzheight - 1prevzheight)
Variable - Set 1prevzheight = 1currzheight
Variable - Set 1heightofjump = (1currzheight + magnitude)
Unit - Change P1Unit height to (1heightofjump - (Ground height at point1)) over 0.1 seconds Debug - Display (Text(1heightofjump) with 6 decimal places) as debug output using Type 1, and Do display it in the game window
That should make it easier to read. Now I'm going to actually figure out what it means.
After the trigger runs a first time, 1currzheight and 1prevzheight are both equal to (Ground height at (Position of P1Unit), and they never change from this value. The second time the trigger runs, magnitude is set to 0, and it never changes from this value. Which means that 1heightofjump is now equal to (Ground height at (Position of P1Unit) Which means that (1heightofjump - (Ground height at point1)) is equal to zero, which means after the first time, every time the trigger runs, the units height will be set to zero.
In this kind of situation, it's useful to print out all of the variables as a debug message. If you'd done that, the problem would have been fairly obvious.
I think that setting 1currzheight to the unit's height (rather than the ground height) will make it work how you intended, but I'm not really sure.
i have only been able to figure out how to debug 1 value at a time, any help?
@irushu: Go
Use the Combine Strings function.