D
D
Danil Shitov2020-10-05 20:00:07
Unity
Danil Shitov, 2020-10-05 20:00:07

The character jumps onto the moving platform, and she leaves without him, what to do with him?

I am making a 3d game where my character is a cube, obeying all the laws of physics, he can jump, ride, there are moving platforms in the game, when jumping on which she leaves without him, but with him. It looks like this:
5f7b4b73cd8c3561361785.png
Here is the code for moving the platform:

void Update()
    {
        transform.Translate(0,0,speed*Time.deltaTime);
        if(transform.position.z>30){
        	speed = - speed;
        }
        if(transform.position.z<10){
        	speed = - speed;
        }
       
    }

there are thoughts on how to implement this, suppose that when the cube comes into contact with the platform, then it moves with it , but it moves forward, but you need to go where the platform is, it didn’t work out how to write a vector so that the cube moves towards the platform.
cub.transform.Translate(0,0,speed*Time.deltaTime);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hixac, 2020-10-05
@Hixac

I propose to make you an option when the character collides with the platform, i.e. jumps on it and the collision works, and when he is on it, he moves at the same speed as the platform, back and forth, and when jumping on the platform, it will feel like you are not on the platform, but when walking, just add the speed of the platform to the speed walk.
I hope I didn't make this process difficult for you.
I can be wrong, because I'm not a pro and probably not the best idea I'm giving you :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question