How do I use containsWorldPoint()
I'm trying to figure out how to trigger an event when a body tracked image overlaps a 3D object in screen space. I am getting an error on the first if statement does anyone have any idea why that might be? I'm pretty new to Javascript so it's quite likely that I just messed up syntax.
this is the error
[Scenarium] SyntaxError: parse error (line 6)
at [anon] (HitScript 2.js:6) internal x(2)
// -----JS CODE-----
// @input Component.ScreenTransform HandLocation
// @input SceneObject enemylocation
// @input SceneObject hit
var enemyPos = script.enemylocation.getTransform().getWorldPosition();
if(script.HandLocation.containsWorldPoint(vec3 enemyPos) = true) script.hit.enabled = false;
if(!script.HandLocation.containsWorldPoint(vec3 enemyPos)) script.hit.enabled = true;
I figured out part of it was that I wrote vector 3 in from the API but that part was being descriptive not actually part of the code
My line of code now says this
if(script.HandLocation.containsWorldPoint(enemyPos)) print("hit");
It is no longer throwing an error but It isn't detecting overlap either. I'm wondering which camera its getting its screen space from since I have 2 3D cameras in the scene (one for device tracking)
Hey Luke,
Would be nice if you provide some sort of screenshot of the project, as it is a bit complicated for me to comprehend :/
Cheers,
SirQu3ntin
Hi SirQu3ntin :)
My file is a bit of a mess because I've been experimenting a lot but I'll try to explain the general effect I'm trying to achieve. you can ignore the punch button above the guys head.
I'm trying to figure out how to trigger an event when a 3D tracked object overlaps with a Screenspace tracked object I want to print"hit" to the debugger to test the interaction. I'm using the dancing guy as a test template because his hands overlap. the larger hitbox is a screen space object and the smaller one is
I have 3 cameras. 1 for orthagraphic 1 for body tracking and 1 for device tracking
I want to get the camera space for the 3D object from a specific camera. Currently, I'm using "Camera" but later I want to switch it to "Camera2" because I want to be able to trigger an event when I punch a 3D object. I want to use screenspace overlap as the trigger rather than 3D because I think it will be easier for the user if they don't need to worry about the Z-space of their punch
ultimately this is what I want to punch but I'm using the hand overlap for testing
my script for overlap looks like this
the code has changed a bit since I originally posted this because I am still actively working on it