Crane Pick up script - setting new parent
Hello! I cant seem to figure this out. I have done a lot of research on it since I am new to scripting and Unity. However, the console feedback from this script is saying that:
'collider' does not contain a definition for 'gameObject' and no accessible extension method 'gameObject' accepting a first argument of type 'collider' could be found
I am trying to get this crane hook to become the new parent of the object I want to pick up, and then later drop it off by pressing a key, to become and item by itself again in the hierarchy. Is the collider.transform.parent function, reffering to the "name" of the gameobject I want the parent to be, or the "Tag" of the gameobject?
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class cranepickup : MonoBehaviour
 {
     public Transform parent;
 
 
     // Start is called before the first frame update
     void Start()
     {
         void OnTriggerEnter(collider collider)
         {
             if (collider.gameObject.tag == "CraneHook")
             {
                 print ("Craneload pickep up");
                 collider.transform.parent = HookParent;
                 WorldPositionStays == false;
             }
         }
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 }
 
Your answer
 
 
             Follow this Question
Related Questions
Access variable from different class 1 Answer
OnTriggerEnter Issue - Collider problem 0 Answers
How to call an action from a script that is on the anonymous object you collide with? 1 Answer
Unity 3D(C#) - How to connect more than two box colliders used as triggers? 1 Answer
math.Lerp not correct? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                