Floating platform problem

I’m new here so I don’t have any experience yet. I have a problem. I built up a floating platform for my first game, but when I put the player on, the floating platform goes on but the player is left without moving. What I want is that both move together. How I can solve this problem?

I leave a video with the problem:

Thanks.

A CharacterController doesn’t have complete physics so it doesn’t get pushed by moving surfaces, although it handles moving into a collider correctly. You need to move the object in sync with the platform. This can be done simply by adding the platform’s motion vector to the character or by parenting the character to the platform as long as he is standing on it.

So, how can I do it? (I new a little bit of programmation but not too much)

Thank you!

hmmmm… odd behavior… I did 2 tests… first a first person controller… this code worked perfectly…

function Update(){
	var block=transform.parent.transform;
	block.position += Vector3(0, 0, 0.05);
}

I then tried it with a third person controller and found that it didnt behave the same way… so… I created a trigger box on top of the platform, then applied this code to the trigger box (of course the parent of the trigger is the box, so they move together)

private var originalParent : Transform;

function OnTriggerEnter (other : Collider) {
	originalParent=other.transform.parent;
	other.transform.parent=transform;
}

function OnTriggerExit (other : Collider) {
	other.transform.parent=originalParent;
}

function Update(){
	var block=transform.parent.transform;
	block.position += Vector3(0, 0, 0.05);
}

The first code doesn’t work as well in my game. When I run the game all the scene starts moving.

The second code I don’t know how to put it in my game. How I create a “trigger box” on the platform?

Thanks for the help.

duplicate the object, turn off the mesh rendering. In the collider click the isTrigger button. Attach the trigger to the original object, resize it, the add the code to it.

I have been in unity for about 2 weeks. Finally got a login for this place (they get targeted as spam so it was hard) So I am trying to learn all this stuff too… lol

Wow, it works perfectly but now I have two platform and I have to raise a little more the duplicate one.

Any ideas to create a transparent duplicate or something like this?

Thank you!!!

You mean select the base object, duplicate it (right click on the object, click duplicate) and them move it?

Now I have a duplicate object on the original object. The game works perfectly but the duplicate object is fully visible but it isn’t opaque.
You can see it in the screenshot:

Thanks :wink:

turn off the mesh rendering on the trigger object… :wink:

Thank you so much with your help, it’s very helpful! I’m preparing my new first-Unity game for a school work.

Thanks!

Hi all, i found this thread similar to something i faced lately, i’m trying to use 3d skeleton motion capture rotations to animate an avatar, how can i manage joints absolute rotations ?

I used the script you put I am having the same issue and i folloed all your steps but nothing happen the platform still moves from under my character. What may be wrong here?

I still don’t know. In my game, it doesn’t work.