[SOLVED] Third Person Player Implementation

I’m implementing the third person player from the Third Person Controller | Learn PlayCanvas tutorial into my simulator.

I’m getting the following setFloat error:

I set up the player in the editor to match the tutorial, so I’m not sure what’s wrong. What does this error mean?

1 Like

That seems like an issue with your player entity missing the anim component. Did you setup your player entity to have an anim state graph like the example project does?

1 Like

Ah, okay; I used animation instead of anim.

I’m getting an error now that says Cannot read property 'x' of undefined:

Hi @Lorenzmotors! The problem is probably caused because there are multiple entities in your project with the name ‘Camera’. Because of this, line 7 of the script below uses the wrong camera.



Is the solution to duplicate PlayerMovement.js, attach one to the player and one to the dronecar, name it something else, and then change the Camera entity names?

I’m not sure why you would do this?

That is a possible solution. But in this case I think it’s easier to replace line 7 with the line below, I’m not sure why it is not in the the tutorial project already like that.

    var camera = this.entity.findByName('Camera');

Okay, that seemed to help!

The animation works now, and no errors, but the camera doesn’t follow the player like in the tutorial. I want to implement a dronecase into the simulator.

And, I want to implement a script into the dronecase that does ai face tracking, follow player, take picture/video, take off and land all from a smartwatch-looking-ui, so I need the camera to be behind the player.

I see in your video that your camera is following your player.

I don’t understand this, so hopefully someone else can help you with it.

If you mean the camera of the third person controller you can just set the right position and rotation of the camera in the editor. You can also select the camera to see the view of it. Don’t forget to switch back, otherwise you change the view when you move around in the editor.


Sorry, I meant that the camera doesn’t follow the mouse movement.

There is a problem with the cameraMovement.js script. You have multiple scripts in your project with the same name and this is causing problems.



1 Like

Thank you, I saw that too and deleted one of the cameraMovement's. The player seems to be responding to mouse movements now, but what I meant to say originally is that the camera is 1. stationary, and 2. very high up above the player; it seems to be stuck in place.

The very-high-up problem seems to stem from the Camera Axis positioning.
Camera Axis

When I bring the Camera Axis positioning closer to the player: it makes it seem like the mouse movement isn’t working, because the camera isn’t “following” or “trailing” the player.

The camera is already positioned that way in the editor. Make sure that the camera (and all other children) are positioned the same way as in the example project.

1 Like

So, when I first started this: I went through each of the entities from the example, so everything should match. Is this what you mean by camera positioning?

I know the gameplay view should be right behind the player; following them, but it looks like this:

When I was looking at your project the camera and other children where on the wrong position far above the player. I see you have fixed that now, but the camera in launch in still on the wrong position and is not rotating with the player. You have a couple of camera’s in your project. I can’t find the ‘ThirdPerson’ camera in the hierarchy. Are you sure this one is disabled?


You’re right, it was one of the cameras interfering. I have since renamed them, and got rid of ThirdPerson.

I programmed the dronecase to face-track and follow the player; I made the dronecase a child to the player, but I’m wondering if there’s a more sophisticated way of doing it?

I’ll start a new topic. Thanks for your help with this!

1 Like