Search Unity

Attachment of equipment for transport

Discussion in 'Animation' started by Trild123787898, Jan 6, 2019.

  1. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    When the transport runs up to the object trigger, when you press a key in me, the script that comes to me is parental, the problem is that there is a space between them herehere is the script
    Code (CSharp):
    1. public class Trigger : MonoBehaviour {
    2.      
    3.  
    4.       private void OnTriggerStay(Collider other)
    5.       {
    6.          
    7.           if (other.CompareTag("Player"))
    8.           {
    9.               if (Input.GetKeyDown(KeyCode.E))
    10.               {
    11.                   transform.SetParent(other.transform);
    12.                  
    13.               }
    14.           }
    15.       }
    16.  
    17.  
    18.       void FixedUpdate()
    19.       {
    20.           if (Input.GetKey(KeyCode.R)) {
    21.               transform.parent = null;
    22.           }
    23.       }
    24.   }
    The question is, how is it possible that when you press a key, the script and the hardware will be placed in this way! Is it possible with the help of animation? Or is there another way!