Editor: https://playcanvas.com/editor/scene/700970
Launch: https://launch.playcanvas.com/700970?debug=true
Script: https://playcanvas.com/editor/code/600366?tabs=18715844,18801293,17191804
(buildMode is the script attached to the Builder button, builder is a root script, itemPicker runs the selection script)
My builder script for ETA is nearly complete, as the user can now spawn tiles in any useful position or rotation. But after spawning the tiles, they can’t be selected for highlighting, ruler-ing, or token moving. I think the problem has something to do with the rigidbody of the tile. My rationale is that result.entity on the onSelect() function isn’t being assigned when a builder-spawned tile is clicked. This can be seen with console log messages on lines 103 & 110 of itemPicker.js
// Selection Function
ItemPicker.prototype.onSelect = function (e) {
if(this.debug) console.log('Clicked Onto the screen');
//
// Converts the screenCoordinates from our mouse coursor into world space coordinates to be used for our engine
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);
// do a raycast within our scene
var result = this.app.systems.rigidbody.raycastFirst(from, to);
// if we hit something
if (result) {
// get the entity we hit
var pickedEntity = result.entity;
console.log('Selected Entity Tag:', result.entity);
I imagine that I must have done something wrong when making the rigidbody script on line 66 of builder.js. But I can’t for the life of me figure out what it could have been.