#Unity Better Spinner Physics

30 messages · Page 1 of 1 (latest)

golden kettle
#

i am trying to make a spinner like Fall guys which give some kick to the player when collided with , can someone tell me how can it be done , and why my player is shaking when colliding with the spinner.
NOTE: I have my Rigidbody player in extrapolate + Continues Collision Detection because when using interpolate it shakes in moving , I am using AddForce for movement

#

The rotating spinner is just a collider with a script to keep rotating using normal transform , no rigidbody

mellow carbon
#

try adding a bouncy physics material

golden kettle
onyx pelican
#

If that doesn't work, you may want to change the Rigidbody to non-kinematic and constraint it on all but one rotational axis. You could then use rb.angularVelocity for instance to rotate the spinner. I'd still much prefer MoveRotation if that does what you are looking for

onyx pelican
# mellow carbon Why not

Rotating with transform wont get the hit object to bounce correctly since the rigidbody only notices it's suddenly inside another collider and tries to resolve the overlap without having the proper information about the hit direction and the velocity of the hitting object. In theory it sounds like the two should do the same thing but in practise bumping objects with objects without rigidbody does lead to wonky results

mellow carbon
#

Ohhh true

onyx pelican
#

@mellow carbon Lets say one wanted to create something similar to newtons cradle (similar example due to bouncy collisions). If you moved the ball with transform only and stopped upon contact, the force transfered to the other balls would entirely rely on the distance the ball happened to move through the other one (inconsistent results and likely way too small bounce). If you kept the ball moving after the impact, they would likely all just move as a cluster which wouldn't be accurate for near 100% bouncy balls. Don't really know how well game engine level physics engine would handle newtonds cradle no matter what you do but in this case I'd try what I suggested earlier. Weirdly enough often times the rb.Move... methods with kinematic bodies gives the best results one can get for moving and rotating obstacles (if the body is non-kinematic, the .Move methods are identical to .position but for kinematic, they seem to take the movement/rotation into account. It is unintuitive but seems to do the trick. My best guess is that when the body is kinematic, the velocity and angularVelocity are no longer controlled by physics so the fields are used to transfer that information, .position, rigidbody or transform won't do the same as .Move... though)

mellow carbon
#

WALL OF TEXT

#

no no I understand yeah

onyx pelican
#

Thought so. Writing on mobile so didn't even realize the exctent of my writing blobsweat

golden kettle
#

@onyx pelican Thanks for this amazing explanation , the first solution fixed the shaking of the player , but still no pushing is happening to the player

onyx pelican
golden kettle
onyx pelican
mellow carbon
#

Increase the bounciness of the physics material

onyx pelican
#

@mellow carbon @golden kettle (wall of text warning!) Worth a try but I doubt it fixes anything though and this is the reason why. Lets imagine a situation where one pool ball sits at rest and other ball hits it at speed x. If we assume the collision to be 100% bouncy and disregard things like rotations, all the momentum should transfer to the ball at rest and it should start moving at speed x. Now if we imagine the moving ball to have infinite mass (which kinematic bodies effectively have), the ball at rest should get the speed of the moving ball upon the first impact. Because the other ball does have infinite mass, it will keep moving at the same speed x so the balls will continue in tandem forever. The reason why we don't expect this behaviour in this case though is because neither the spinning bar nor the player is rigid. In fact they should both be soft to some degree which the unity rigidbody won't help you with. In order to emulate that effect, I'd try to add bit of extra force proportional to the impact of the collision that OnCollisionEnter gives to the colliding rigidbody (and divide by Time.fixedDeltaTime according to the docs to get the force from the impulse?).

golden kettle
golden kettle
golden kettle
mellow carbon
onyx pelican
# golden kettle

Good you asked. What happens here seems to be exactly what one would expect from two rigidbodies colliding, the rotating one with infinite mass/power. I think extra force proportional to the impact would be the best way to fake the "softbody bounce" we expect to see

golden kettle
mellow carbon
golden kettle
golden kettle
mellow carbon
#

I would just add a force or impulse at the collision point then