Log in or register to post comments

Help Touch ARcamera Playmaker

December 11, 2014 - 6:08am #1
im using Playmaker with Vuforia, i put a  Touch Object Event to a Cube.
The problem is that with the ARcamera from Vuforia, i need to move very close to take effect the Touch Object Event. How can i expand or another way, to enable the Vuforia touch ARcamera, work at any position? 

Help Touch ARcamera Playmaker

December 18, 2014 - 6:21am #8

Hi,

you really shuld lookup this on the Unity forum, there are loads of examples plus the Vuforia examples have the same kind of this included too ;-)

 

 

Help Touch ARcamera Playmaker

December 18, 2014 - 6:13am #7

i put the script in C# and give this error.

A namespace can only contain types and namespace declarations
 
ho can fix it?

Help Touch ARcamera Playmaker

December 18, 2014 - 12:25am #6
void Update () {
		
	// test for touch 
	if (Input.touchCount > 0) {
			 
		// grab reference to this touch
		Touch userTouch = Input.GetTouch (0);

		// ray from cameara to point of finger touch
		Ray ray = Camera.main.ScreenPointToRay(userTouch.position);

		// hit object to record details of what was hit (touched)
		RaycastHit hit;

		// if we got a hit and it was on one of the gameobject
		if (Physics.Raycast (ray, out hit) && hit.collider.gameObject.name == "name of gameobject" ) {

			if (userTouch.phase == TouchPhase.Began) {

			}
			else if (userTouch.phase == TouchPhase.Moved) {
			
			}
			else if (userTouch.phase == TouchPhase.Ended || userTouch.phase == TouchPhase.Canceled) {
			
			}
		}
	}
}				

 

Help Touch ARcamera Playmaker

December 17, 2014 - 11:33am #5

can u show me the rest of the script to complete this.

// if the hit was on the Collider object
if (Physics.Raycast (rayout hit) && hit.collider.gameObject.name == "Name of your object") { // do what you want}

I attach the script to the camera?

Help Touch ARcamera Playmaker

December 17, 2014 - 3:39am #4

Head over to the Unkity forums as this is not a Vuforia related query, but...

 

// grab reference to this touch
Touch userTouch = Input.GetTouch (0);
                
// ray from cameara to point of finger touch
Ray ray = Camera.main.ScreenPointToRay (Input.GetTouch (0).position);
                

// hit object to record details of what was hit (touched)
RaycastHit hit;
                
// if the hit was on the Collider object
if (Physics.Raycast (rayout hit) && hit.collider.gameObject.name == "Name of your object") { // do what you want}
            

Help Touch ARcamera Playmaker

December 16, 2014 - 8:00am #3

How you add raycast, i a script?

Help Touch ARcamera Playmaker

December 16, 2014 - 7:50am #2

I don't know what playmaker is but when I want to add touch events to my objects I add colliders with the required size then raycast....not sure it that is right, but works perfect for me

Log in or register to post comments