Both the tutorials and the API are out of date

To quickly summarize what I’m trying to do, I’m trying to make a multiplayer FPS game, kinda like CS1.6.

I tried following one of the tutorials from the main page: http://developer.playcanvas.com/tutorials/advanced/fps-controller/

Which basically summarizes the movement that I want within my game. However, none of the code supplied there works. I get undefined errors for things that should be in the framework. eg:

TypeError: this.entity.rigidbody is undefined
TypeError: pc.math.vec3 is undefined

When I go to the API docs, there is no reference to pc.math.vec3, but I tried using pc.Vec3, and it worked. I’m pretty sure this is because they’re renamed a bunch of functions, and not updated the API, which kinda makes it hard to learn. The API directly references this.entity.rigidbody, and it simply gives me undefined.

Here’s my code if it helps. I’m trying to make a character entity move with wsad and up down left right. This script is applied to the entity and not just the camera.

Hi,

Sorry you’re having trouble.

So, first, I’m assuming you’re talking about your project at https://playcanvas.com/taiiwo/Sandbox if that’s not the case let me know.

The property this.entity.rigidbody refers the the RigidBody component on your Entity. In the case of your Pack the Entity with the script component attached “Character” doesn’t have a rigidbody component. So, in the Designer, add a rigidbody component and a collision component, and that should work.

As for your Vec3 problems, you are right, we changed the API from pc.math.vec3 to pc.Vec3 a little while ago. Can you send a link to where you can see references to pc.math.vec3. There shouldn’t be any of those left. I can’t see any on that tutorial page.

Also worth noting, that the way to create vectors requires new:

var vec = new pc.Vec3();

Which I notice you are missing in some of your code.

Hope that helps, let me know if there’s anything else you need.

Ah, thank you sir. I did just figure out the rigid body thing. I used the source from the bitbucket repo linked to in the tutorial: https://bitbucket.org/playcanvas/tutorials

I used this particular file: https://bitbucket.org/playcanvas/tutorials/src/54c7046ebc090ebd84a8225d006ea43e24ec1cba/characters/dynamic_character_controller.js?at=default

Other than this, I’m really impressed so far. I hope to finish my counter strike clone soon. Having lots of fun!