Player fall from moving platform (SOLVED)

Hello! I making 3d game when player jump to moving platform. Moving platform throws off a player when he stays on it. How stick player on the moving platform, but allow him to move?

Upd:
Player - dynamic physics type
Platform - kinematic physics type

Using a dynamic collision object in a platform game is hard because an object that’s affected by gravity, friction, momentum, restitution and so on can’t be easily manipulated without getting strange results. You’ll be fighting against a physics engine if trying to do non-physicsy things such as sticking to a platform in only one direction. Unless advanced physics simulation is part of the key game mechanic, you’re most likely better off with a kinematic player object.

If you’re sure a dynamic is the way to go, there are a few things you could try:

  • Set the player game object as a child to the platform when it’s connecting, and then move it to root (by setting parent to nil) when not connecting.
  • Set the player game object’s position every frame to match the platforms y position (to allow movement in the x axis)
  • Set the player game object’s collision object’s linear_velocity to to match the platform’s movements in the y direction
  • Increase the gravity when the player touches the top part of the platform, to press against the surface.

However you do it, making a dynamic collisionobject bend to your will is going to be hard work. Good luck! :smiley:

6 Likes

solved by adding a trigger and disabling the dynamic body:

		if message.enter and message.other_group == hash("moving_platform") then
			if not onMovingPlatform then
				onMovingPlatform=true
				msg.post("#collisionobject", "disable")
				go.set_parent(go.get_id(),message.other_id,true)
			end
		else
			if onMovingPlatform then
				onMovingPlatform=false
				go.set_parent(go.get_id(),nil,true)
				msg.post("#collisionobject", "enable")
			end
		end
2 Likes