ShiVa3D
touching on a item [SOLVED]
All about the StoneScripttouching on a item
by juno1990ahn » 02 Jul 2012, 10:45
Hello everyone I just started using Shiva and I am having problems already hehe.
I'm trying to make it so the AI will detect if the model was clicked or not.
I want to use the onTouchSequenceChange but how do I detect if my touch started from
the model and ended at the model without moving out of the model in between?
I want to make sure the user doesn't drag their finger into the object or out of it while triggering my event.
This is a code I took from another topic and I'm triggering the event in onTouchSequenceEnd if hTouchedObject is not nil
I'm trying to make it so the AI will detect if the model was clicked or not.
I want to use the onTouchSequenceChange but how do I detect if my touch started from
the model and ended at the model without moving out of the model in between?
I want to make sure the user doesn't drag their finger into the object or out of it while triggering my event.
- Code: Select all
if (nTaps0)
then
local camX, camY, camZ = object.getTranslation ( application.getCurrentUserActiveCamera ( ), object.kGlobalSpace )
local nRayPntX, nRayPntY, nRayPntZ = camera.unprojectPoint ( application.getCurrentUserActiveCamera ( ), nX0, nY0, 0 )
local vX,vY,vZ = math.vectorSubtract ( nRayPntX, nRayPntY, nRayPntZ, camX, camY, camZ )
local nRayDirX,nRayDirY,nRayDirZ = math.vectorNormalize ( vX, vY, vZ )
local hHitObject, nHitDist, nHitSID = scene.getFirstHitSensor( application.getCurrentUserScene ( ), nRayPntX, nRayPntY, nRayPntZ, nRayDirX, nRayDirY, nRayDirZ, 500)
if ( hHitObject )
then
this.hTouchedObject ( hHitObject)
end
end
This is a code I took from another topic and I'm triggering the event in onTouchSequenceEnd if hTouchedObject is not nil
- juno1990ahn
- Fresh Boarder

- Posts: 12
Re: touching on a item [SOLVED]
by capiright » 04 Jul 2012, 22:31
I am using the same code but you have to watch it.
Tip 1: have a special sensor ID for tap interactions and use the getFirstHitSensorwithId method.
Tip 2: put a log call in your if call where you validate the target. Then place a log on the touch end and see what's going on
Tip 1: have a special sensor ID for tap interactions and use the getFirstHitSensorwithId method.
Tip 2: put a log call in your if call where you validate the target. Then place a log on the touch end and see what's going on
You know you like us...
http://www.facebook.com/SunDriedGames
http://www.facebook.com/SunDriedGames
-

capiright - Platinum Boarder

- Posts: 516
3 posts
• Page 1 of 1