why doesnt this work, i parented it to the camera
var Raycast = pc.createScript(‘raycast’);
Raycast.attributes.add(‘color’, {type : ‘rgba’});
// initialize code called once per entity
Raycast.prototype.initialize = function() {
this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.mouseDown, this);
};
// update code called every frame
Raycast.prototype.update = function(dt) {
};
Raycast.prototype.mouseDown = function(e){
this.doRaycast(e.x, e.y);
};
Raycast.prototype.doRaycast = function (screenX, screenY) {
var from = this.entity.getPosition();
var to = this.entity.camera.screenToWorld(screenX, screenY, this.entity.camera.farClip);
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if (result) {
this.app.renderLine(from,to,this.color);
}
};