I want to know whether the mouse points to an entity to change the pattern of the mouse. For example, when it points to an entity, the mouse changes from an arrow to a small hand, and I found this:
API: screenToWorld
API: raycastFirst
this is my code:
TouchEvent.prototype.onMouseMove = function(e){
var camera = this.app.root.findByName('Camera').camera;
var clickX = e.dx;
var clickY = e.dy;
var start = camera.screenToWorld(clickX, clickY, camera.nearClip);
var end = camera.screenToWorld(clickX, clickY, camera.farClip);
// Use the ray coordinates to perform a raycast
this.app.systems.rigidbody.raycastFirst(start, end, function (result) { // line 44
console.log("Entity " + result.entity.name + " was selected");
});
}
but I got this error:
playcanvas-stable.dbg.js:43626 Uncaught TypeError: Cannot read property 'setValue' of undefined
at RigidBodyComponentSystem.raycastFirst (playcanvas-stable.dbg.js:43626)
at scriptType.TouchEvent.onMouseDown (TouchEvent.js?id=40894533&branchId=bd4b1e76-80cc-42f7-909e-4a2dc7758838:44)
at Mouse.fire (playcanvas-stable.dbg.js:590)
at Mouse._handleDown (playcanvas-stable.dbg.js:56219)
raycastFirst @ playcanvas-stable.dbg.js:43626
TouchEvent.onMouseDown @ TouchEvent.js?id=40894533&branchId=bd4b1e76-80cc-42f7-909e-4a2dc7758838:44
fire @ playcanvas-stable.dbg.js:590
_handleDown @ playcanvas-stable.dbg.js:56219
I don’t know why,help me please