0

So ive been following a tutorial to make it so when a playerobject goes onto a moving platform, it moves with that platform. The issue is that my playerobject doesnt move with the platform, ive tried alot and still cannot get it to work, Is there anyone who could help me out?

My player object has a Ridid Body and Capsule Collider with isTrigger unticked. My platform has a Box Collider with isTrigger unticked. The code below is attached to the platform.Code for moving with platform

Ive tried doing the exact same on another unity project and still getting the same issue.

z Slav
  • 1

2 Answers2

0

Please, post your code in the question. Not on a separate image.

Instead of comparing the name of the object, use the TAG system.

if (collision.CompareTag("TAG")){
    // Do your thing
}

And set the tag your comparing into the player.

You can check Unity docs if you have any other doubts about CompareTag.

Raphael Frei
  • 361
  • 1
  • 10
-1

When checking the object name you are using:

collision.gameObject.name == "PlayerObject";

I think a better way is to use:

collision.gameObject.tag.Equals("PlayerObject");

In the Unity Inspector, you can assign tags in the upper area.

Emil
  • 59
  • 5