Search Unity

Having issue with moving child up y -axis

Discussion in 'Scripting' started by Jeriko2k3, May 22, 2015.

  1. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    Ok what I am attempting to do and to some extent succeeded is to have an object on a plane turn into the child of the player object. Which I have done. I am wanting the child to now rotate around the player object up the y-axis to be destroyed at a certain point. I can get the child object to rotate however I have had no luck in making it go up.

    Any help would be great.

    Thanks.





    Code (CSharp):
    1. {
    2.    
    3.     public Transform a;
    4.     public Transform b;
    5.    
    6.     void OnCollisionenter(Collider other)
    7.        
    8.     {
    9.        
    10.         if (other.gameObject.tag == "c")
    11.            
    12.         {
    13.            
    14.             other.transform.parent = transform;
    15.                        
    16.         }
    17.         b.transform.RotateAround (a.transform.position, Vector3.up, 365 * Time.deltaTime);
    18.          }
    19. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,744
    You are probably going to want to use a coroutine to do the entire effect.

    Review the StartCoroutine() method and then you would rotate and lift the child object's transform.localPosition value over a period of time, then (for example) destroy (or hide) it.
     
    Jeriko2k3 likes this.