platform

Hi, Hoping someone can point me in the right direction. I have a moving platform, no code, just a platform moving up and down, a .anim file created using the animation tab. When I jump on the platform, when moving down the player jerks abit and i presume this is just the acceleration of the physics etc (when moving up its fine). I’m not sure how to fix this though, any ideas?

Thanks

Dave

Hi,

I was just testing/experimenting with the same issue;

“Animate Physics” might help a bit. But for the best result you probably will need to set your player as a child of the platform while he is on the platform.

1 Like

PGJ: Not much help to use parenting if child object and platform are rigidbodies I think, but I might be wrong.

Personally, I couldn’t get any good results from “Animate Physics” setting. It does not seem to be working / helping Unitys 2D Physics / box2d stuff, it seems? There is at least one article about using that setting, but it was for 3D physics.

2dgamemania: I’m not sure if 2D physics is used, but I guess that might be the case.

Hi there, really appreciate the feedback. I checked animate physics and this did help, not perfect but it did help. I think I’ll use animate physics for now but will probably have to create a script later on so that if the player is on top of the moving object it recognises this and the y value of the player is matched with the moving object. Thanks guys

relooking at the animate physics option it wasnt that good so coded it manually, so if player is on the platform (used layers to check if grounded) then move player y direction with moving platform, works well just shame wasnt a easier route.

It’s easier to parent the player to the platform, then he will move along with it automatically. Once the player moves off the platform, you reparent it to the scene.

2 Likes

PGJ: Now that I did quick test based on your suggestion, it actually seems to be a good solution;

  1. Make platform have Rigidbody2D, make it kinematic, make it animate using script or animation.

  2. Then make your character have Rigidbody2D and make it non-kinematic.

  3. For parentation on triggerEnter or such use SetParent and onTriggerExit set transform.parent to null.

On collision to fast moving platform (at least vertical) character starts and continues to stick to platform like glue (visually, that is). Yet it’s possible to walk and jump of the platform and movement of platform still affects character in good way.

So your answer nulls my thread about moving platform I think - Thanks! :slight_smile:

2 Likes

thanks guys, i’ve made a note for now as that might be an easier way next time.