Log in or register to post comments

User Defined Targetposition game object problem

May 17, 2019 - 12:37pm #1

 HI, 

I'm newbie in Vuforia and I can't understand why my code make properly only one. 

The imageTarget object is taking only once, then I see some paint in scene.

That one painting point is rotate properly with the userImageTarget.

Every next paiting point appear but rotate only with device, independently my userImageTarget,

but the new object paint (represent clone object) have a parent from  imageTarget.

Unfortunately new pait object haven't any parent, I don't know what I should to do.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

public class WritingBehaviour : MonoBehaviour

{

    public GameObject paint;

    public GameObject imageTarget;

    void Update()

    {

        if (Input.GetMouseButton(2))

        {

            imageTarget = GameObject.Find("UserDefinedTargetBuilderRys");

            GameObject clone = Instantiate(paint, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation) as GameObject;

            clone.transform.parent = imageTarget.transform;

        }

        if (Input.touchCount > 0)

        {

            imageTarget = GameObject.Find("UserDefinedTargetBuilderRys");

            GameObject clone = Instantiate(paint, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation) as GameObject;

            clone.transform.parent = imageTarget.transform;

        }

    }

}

Log in or register to post comments