#How to control the behavior a collider has when falling on an edge

1 messages · Page 1 of 1 (latest)

fluid otter
#

Hello, I’m trying to control the behavior of my capsule collider so that it behaves the way I want when falling on an edge. I’m still not sure how to do what I want which, in the end, on paper, is pretty straightforward :

You know how gravity makes a Rigidbody fall ? And you know how if a Capsule collider is on an edge with the center not touching the ground, it kinda slides off to end up falling ?

Well with regular physics, it will slide faster the further away from the edge the capsule “sphere center” is.

What I want is for it to slide off as quickly as needed so that we keep that 9.81 m/s2 vertical acceleration. Which would give that effect :

https://forum.unity.com/attachments/pushed-gif.1310018/

Apparently I should hook into the contacts and perform what I want based upon them using Physics.ContactModifyEvent, but I don’t know how to do this.

Can someone please help ?

Thanks !

neon brook
#

can i propose an alternative solution?

fluid otter
#

Yeah sure go ahead so long it does what I need, it’s good 😊

neon brook
#

why not just compute the vertical velocity the player should have at every height. like at 20 m above the ground it has n downward velocity or at 10 m above the ground it has n + idk velocity

#

and if the player doesn't have that velocity, set the y velocity to the velocity it is supposed to have

fluid otter
#

The gravity calculation is to complex for that plus it takes into account a time scale for time slow down/stop powers. It wouldn’t work that way. Also, how do you jump ? Or anything ? That would bring a million conditions to make that work. Hooking into contacts certainly is the way to go, I’m just not sure what to do

neon brook
#

when you fall, is gravity the only thing that can affect your velocity?

#

for your solution, how will you modify the contact point?

fluid otter
#

No, other actions can affect velocity, and about the contact point, I have no idea, hence my question x)