Add impulse and launch char at edges(cliff side)

As the title says, when at the cliff side it launches the character like across the world. But when on ground it works like a “side step”.

I’ve tried both add impulse and launch char. They both do the same thing when used near a platform edge.
I’m gonna try launching the char into the floor and then left or right… but i hate adding extra code to “fix” something that there seems to be a proper way for. Extra code means extra bug potential.

Any ideas?

Please explain what you mean by a side step, please provide diagrams/drawings if needed

Thanks!

like a dash left or right.
I have it set up where when i double tap left or right the char will “dash” as if avoiding something.

So I get right vector. * it by x amount and it will “launch” the player left or right depending on the direction held.

I have it set to 2000 and im using add impulse. It quickly shuffles the char left or right about 3 feet for a “quick dodge” motion. The issue is when standing on the edge of a cliff and doing it, it launches the char like 100 feet instead… obviously because it goes from land to in the air.

I agree with you about the extra code/bugs XD

Could you show the graph of how you’re calculating the force to Add Impulse? Is it using the result of a Line Trace or what?

One thing you could do is not use forces and use interpolation of your position so that you can better control the side stepping motion and as mentioned above, you could use a raycast to determine how far down, etc,

sure. its a bit ugly since im just testing the results between launch and add impulse…

no ray trace for this… I’m just literally pushing the char left or right or forward or back.

heres a vid of what I mean

You are applying force every frame for the duration of the force?

CyberblastSoft’s solution offers a lot of control, indeed. My guess is your character is flying away due to the lack of friction with the ground.
If you really want to use physics, I’d start by putting a little “UP” to the side vectors, so it takes the character out of ground. Then you can test what the motion looks like without the ground friction, making a small arc in the air. Like a side jump.

If you think about it, quick side steps in real life would really send you away if it wasn’t for the landing foot to stop you from doing it.

Also, multiply some force, say 5, by the gravity force (980 is the default) times your character’s mass. So you’re guaranteed to take him off ground, at least. Like, if you’d levitate him, it would take an upwards Add Force with his mass multiplied by the gravity force. It’d effectively keep it still in the air, with physics enabled.

good call.
up and over seems to work pretty well.

I havent got into the math yet… I just did a quick test with launch char. Adding RIGHT and UP vectors together and then multiplying them by a float amount (200). Works pretty well. A little too up though. I think i’ll break the vectors specify their force indivudally before adding them together so i can control the up and right individually.

Thanks guys for the suggestions.
I’ll look into the interp option as well. Have use it for rotations but not for setting locations.

Glad it helped =)

About mixing the UP with the SIDE vectors, just get your SIDE vector, add the UP to it and then normalize.
At first it’ll be very up, as it is now, but since you can create the UP by hand, as it’s (0,0,1), you could start shrinking it before adding to the SIDE vector doing something like (0,0,0.5). It’ll diminish the UP effect a little.

I just ran into this problem, and tried a lot of solutions including turning off friction. The results were super janky, but then I realized I was going about it wrong. The solution is really simple:

Apply an impulse ( multiplied by time delta ) in the roll direction whenever the player is both rolling and on the ground.

That’s it, just stop applying the force when the character is in the air. No need to mess around with friction or launch the character off the ground.

Update:
Switched from add impulse to add force, it works better over the network.