Third Person Controller template with touch support

I’ve modified the Third Person Controller template and added touch support.

Project:
https://playcanvas.com/project/721980/overview/third-person-controller

Play:

3 Likes

Thanks for sharing, it works great!

1 Like

:slight_smile:
Thanks!!

I’m getting a warning in the console:
script ‘playerAnimationHandler’ is already added to entity ‘Model’

Any idea why?

That is just a warning, most likely somewhere in code or in editor you’ve tried adding the same script to the same entity?

Hmm… I don’t think I did that. But I’ll have another look.

1 Like

hey… your project will showing error while I play it with keyboard.
This error is showing because this.app.touch is null when I play with keyboard.

So I put those codes inside if(this.app.touch) {}
It work fine but Camera will not moving when I flow my mouse.

Please have a check and it will be best sample project.
PLEASE HELP !!!

Successfully merged this project with the original project of the tutorial.

The changes are as follows:

  1. Integrate all touch control scripts into scripts with the same function (CameraMovement.js, PlayerAnimationHandler.js, PlayerMovement.js)
  2. Fix the problem that the mobile terminal cannot control the camera caused by devicePixelRatio (otherwise x is out of range)
  3. Optimize part of the code to make it more concise
  4. Optimize the transient problem when the camera pitch passes 90° to improve the interactive experience (refer to UE4 third-person template)

Project:
https://playcanvas.com/project/770783/overview/third-person-template-x

Play:

Hope to be able to intergate into the tutorial project :wink: @yaustar

1 Like

Only one question: the camera was initially facing the player, which made me very uncomfortable. I tried to fix it but failed.

Nice! Many thanks for sharing.

For the initial facing angle to make it match add 180 to the Y axis rotation of your Player entity:

1 Like

Awesome work @kprimo :grinning:I’ve been a bit busy lately so I couldn’t help out @11144 with the error.

Hey @kprimo I noticed a minor bug in your version which isn’t present in my version. On mobile, when you are moving and looking around at the same time and then you stop moving while you are looking around, the character will stop moving but the moving animation doesn’t stop.

I’ll check it. Thanks for your feedback.

can we use this also in the multipayer mode?