Set static position when on object

Hello guys i have a little issue in my project, i have a moving platform inside, when player is on the platform i want him to stick on that and not move until he decide to move, because now when i jump onto platform my player is just not moving and fall down / slide down

here is link for Play: https://launch.playcanvas.com/1025730?debug=true

HOLD UP ARROW KEY TO MOVE.

Thank you for every help

you could add the entity of the person to be a child of platform entity (with some local position offset)

or

you can move position of the person each frame to keep it on the platform … so basically get world position of platform, and set world position of character to it plus some offset again

1 Like

First method seems to be better, is there any way i can set my player to be child through the code ?

this should do it
https://developer.playcanvas.com/en/api/pc.Entity.html#reparent

Okay so, reparent(parent, [index]) - how do i use it? ‘parent’ should be name of the Object i want to set parent for my child? and index is the place number, for example 1.

i want to set it under platform, which is child of trap_03

image

for each platform there is set a script for rotating object

so this line is not working
entity.other.reparent(this.entity[1]);

my player is hitting a collider so thats why entity.other

EDIT: actually it seems that it is set as child but it doesnt really help so i dont know, play canvas is missing the really good thing that Unity has, and that is you can check your editor with ingame changes

so i could easily check if it was set as a child :confused:

I tried using the childing method, but that didn’t work for some reason and gave an error. So I instead just set it’s y velocity to 0, which somewhat works.

That quite didnt help to me much

image