i have an issue with the code i looked at scripting and i think i did it correct.
SCRIPTING:
pc.script.create('PickerRaycast', function (app) {
// Creates a new PickerRaycast instance
var PickerRaycast = function (entity) {
this.entity = entity;
};
PickerRaycast.prototype = {
// Called once after all resources are loaded and before the first update
initialize: function () {
app.mouse.on(pc.EVENT_MOUSEDOWN, this.onSelect, this);
},
onSelect: function (e) {
var from = this.entity.camera.screenToWorld(e.x, e.y, this.entity.camera.nearClip);
var to = this.entity.camera.screenToWorld(e.x, e.y, this.entity.camera.farClip);
app.systems.rigidbody.raycastFirst(from, to, function (result) {
console.log("Entity picked is: " + result.entity.name);
});
}
};