I’m using the raycasting method at the moment but here is something I tried, but it didn’t work. What am I not seeing?
TapObject.attributes.add('idleAnim',{type:'entity'});
TapObject.attributes.add('attackAnim',{type:'entity'});
var idle = true;
this.app.systems.rigidbody.raycastFirst(from, to, function (result) {
var pickedEntity = result.entity;
if(pickedEntity === this.idleAnim){
idle = false;
} else if (pickedEntity === this.attackAnim) {
idle=true;
}
});
The frame buffer method seems a legit way of controlling what is being clicked, but I have a feeling there may be a simpler solution.
Perhaps making a script that can be attached per entity versus the camera? Or some use of arrays? I do not know much about arrays, or ways to use the ray tracing technique to solve this problem. I’ll keep digging but would love some help on this. thanks.
and for the record i do have the intializing code i just didn’t include it so you can get to the root of the problem which is somewhere found in the if(pickedEntity === this.idleAnim)
Because I have simple code now that makes it do what I want, but the issue is it doesn’t matter what entity I click on.
Raycasting using physics objects with a physics system (either ammo.js which is what PlayCanvas supports natively or one of the other major Javascript physics library. If using ammo.js, then you will need to enable physics in the project settings and give each entity a rigidbody and collider that you would like to raycast against) Example here.
It seems like the last option you sent works the way I would intend, but I don’t know for sure.
Because I can see that only the BOX will get spheres, where the plane does not. What I like about that project example as well is that it doesn’t need a collision box. It seems pretty focused on the attributed ‘Box Entity’
This is idea because I think if I can backwards engineer this to be instead of ‘Box Entity’ I can have it be ‘Up’ ‘Down’ ‘etc’ Then use the functions within the script to do unique functions based on what was actually ray casted.
Are you trying to make on-screen controls? If so, you probably better off use the sprite buttons like Will has done here for the UI in Flappy Birds (Start button on the title screen) https://playcanvas.com/project/375389/overview/flappy-bird
Yes the answer seems to clearly be in the example that Will did, @yaustar
It’s overwhelming but I’ll try to decipher this the best I can, thanks very much!
Also sorry for the spam! Got way too excited. Keep in mind I have been pretty good about scouring the User Manual, but it has quite a bit of info, I’m just taking bit by bit on as it comes. Thanks again for your time and patience. I understand some of my questions may be super easy possibly to answer I’m just clueless to a lot of this.
Spent almost 2 hours trying to figure this ish out.
And well I got it to do as I was hoping. I wanted to understand the code, not to simply copy and paste, so I think I got a good handle on it.
Here is a gif of how I got the code to work for me. Simple touch the dudes they change animations.
With this problem solved, for now, I think I’ll be able to make Ultra Mech Show Down now lol.