ammoRayStart.setValue Undefined


I’ve pretty much copy pasted the Raycast tutorial code into my project but i’m getting an error on one of the source files.

Uncaught TypeError: Cannot read property ‘setValue’ of undefined
at RigidBodyComponentSystem.raycastFirst (playcanvas-stable.dbg.js:29141)

var MyRaycast = pc.createScript(‘myRaycast’);

// initialize code called once per entity
MyRaycast.prototype.initialize = function() {
// Find the first entity in the hierarchy with the name ‘Camera’
this.cameraEntity =‘AR Camera’);

// Setup the different positions to move to
this.firstPosition = new pc.Vec3(-1, 1.25, 6.5);
this.secondPosition = new pc.Vec3(1, 1.25, 6.5);

// Add a mousedown event handler, this.mouseDown, this);

// Add touch event only if touch is available
if ( {, this.touchStart, this);


MyRaycast.prototype.mouseDown = function (e) {

MyRaycast.prototype.touchStart = function (e) {
// Only perform the raycast if there is one finger on the screen
if (e.touches.length == 1) {

MyRaycast.prototype.doRaycast = function (screenPosition) {
// The vec3 to raycast from
var from = this.cameraEntity.getPosition ();
// The vec3 to raycast to
var to =, screenPosition.y,;

// Raycast between the two points
var result =, to);

// If there was a hit, store the entity
if (result) {
//Do Stuff.


Can anyone help?


Do you have public link to the project or the rest of the callstack?


I’ve built out a project with the same issue here;

I’m reviewing on Chrome.



Your physics in the project settings is not enabled


This also means that you haven’t added any physics objects in the scene to raycast against otherwise this would have automatically been set.