Jump & Bounce Functions w/ Gravity Physics
This is an example of my gravity jump & bounce functions / formulas
The functions allow you to set unit, height, gravity, update speed, movement lock, animation, animation lock, and % energy lost during bounce parameters.
Gravity: The lower the # the faster the unit jumps up and falls down. Must be negative. Default is -9.8. Looks better at around -20 though.
Update Speed: This is the speed at which the unit's height is updated. The lower the # the faster it updates. It's usually good at 0.1 or 0.05.
Movement Lock: Locks the unit's movement while its jumping. Causing it to keep moving in one direction until it lands then it goes back to its initial orders. Makes the jump look more realistic.
Animation: The animation you want the unit to play while jumping.
Animation Lock: Locks the animation shortly after jumping.
% Energy Lost During Bounce: This changes the height of the bounces after the first one. Must be between 0 and 1.0. Default is 0.15
You can make your trigger "wait" for the function to complete by unchecking the "Create Thread" option in the function.
Feel free to use it however you want...
(Edit : Sorry to update dead post : /) Hi there ! First, thanks a lot for making this function, so usefull ! Then, i have some questions : )
1- If I apply the function when the unit enter a region, and no when user press a key, it doesn't work : / Why ?
2- Xenrathe, how do you "give units a behavior with modification: Plane Delta: Ground -1 & Air 1" please ?
3- I have an error when unit lands : "CActorUnit[myunit]CActorMsg[AnimSetPaused {} 0]; This message needs a valid name for an active animation".
Thanks
Hey Xenrathe,
I'm trying to modify this so that the unit will go over cliffs when jumping. Where exactly did you put in the add behavior and remove behavior in the trigger? And what did you put for the unit?
I tried adding the behavior before the "cause unit to jump" action in the "jump" trigger, using picked unit and that yielded no results.
I dunno about jumping over unpathable areas but... I can make it so the unit doesn't keep trying to move past unpathable terrain during the jump.
That's what you mean right?
Could you give an option that allows units to jump over unpathable blocks.
Basically make it check if the target location is pathable and if not make it jump to the furthest pathable point along the line between the unit and the target.
hmm... i'll give it another try.
You don't need to change a unit's mover on the go, if you give units a behavior with modification: Plane Delta: Ground -1 & Air 1, then the unit should path like it were an air unit. At least mine does, and that's the only way in which I altered movement.
nice advice xenrathe. i'll put it in the description so people can make their unit jump up terrain.
i'll try and put that into the example map.
edit: apparently you can't change a unit's mover on the go. dead end. :|
Sorta similar to the lift function I wrote.
I agree that -9.8 doesn't look realistic, but it depends on your update speed. Also to turn the unit into a flyer, just add a behavior at the beginning of jump that sets Ground-plane = -1, Air-plane = 1 (look at the Phoenix Anti-gravity behavior), and take the behavior off once it lands. I also made it so that melee units can attack air while they are up there... nothing like watching a bunch of zerglings jump into the air to take a banshee down. There's a lot of ways to do that; for example by enabling/disabling weapons via the above behavior.
Cheers!,
Xen.
Edit: I think think you might need to useCatalog Field Value Set. I'm just learning about this, but apparantly you can use it to change data field values. Maybe you can access the mover with this trigger. :) Happy Mapping!
That's kinda what I was thinking Renegade. Maybe some how make a trigger that turns him into a flyer when the jump begins. That would be so sweet!! There are ways to change that data with triggers, Im just not sure how. =P
Loving the physics so far! its amazing! Thank you for adding the keeping its course thing i suggested :) I was wondering if instead of making that unit uncommandable to just instead make the unit a lot slower in movement.. you know cuz you do have some sort of mobility in the air i suppose? Also it would make it so units could attack in the air too which would be cool. Or you could just disable movement because we don't exactly have mobility in the air.. Maybe turning only?
I'm just rambling on here sorry :P. Just some friendly suggestions keep up the good work.
@nateZinger
Sure I can add a variable that increases / decreases the unit's speed while jumping.
@Southpaw444
I tried and tried to figure out a way to do that with only the trigger editor.
Turns out you need to make a behavior in the data editor that changes the mover of the unit to glider or flyer. Some nonsense like that. I'll look into it.
This is way cool.
Any chance we could define the distance of the jump too? (at least for when we have the Movement Lock on). It seems right now that the rate of which the unit moves forward is just the same as the unit's movespeed, but it would be cool if the variable could be adjusted too. :)
Thats really awesome! Is it possible to make it so you can jump up and down/over terrain? Or does it already do that?
Thank you, very well done !
ah crap i did upload the wrong file. my bad.
yea -9.8 should be realistic but it seems slow. i dunno why. all the physics equations are correct but maybe thats the nature of the way i made it.
if you set it to more around -20 it looks more authentic.
seems like the units travel faster when jumping upward, and slower when falling.
9.8. Are all the other related parameters matching units? 9.8 was used so that it seems as most realistic right? but it looks way slower than realistic.
i think you posted the wrong map file with this...
did u u se data editor or triggers? nice thing btw :)
i'll make it* dyslexia ftw...