- Home /
How to keep player character on top of a Rolling game object?
I want to keep my rigidbody character on top of a rolling game object where he jumps on and the game object will keep rolling and moving towards left. I tried using freeze rotation but the character still slides off on the rolling game object.
Here's a sketch of my probem:
Answer by Cornelis-de-Jager · Jan 16, 2019 at 01:56 AM
Create an invisible platform above the ball. Add a script to the platform so that if hovers above the ball.
public class PlatFormFloat : MonoBehaviour {
public Transform ball;
void LateUpdate () {
transform.position = new Vector3 (ball.position.x, ball.position.y + ball.size.y / 2f, ball.position.z);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612185834im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player Character looses jump height the further right they go 1 Answer
If you change the rigidBody2D.position, you also need to change the gameObject.transform.position? 0 Answers
Simple Rigidbody2D movement and jump 0 Answers
Problem between my player jump and player movement 1 Answer
Getting a Script without setting a variable to the script name 1 Answer