Right, so I’m probably going to feel stupid after asking this because I had it working yesterday but when tweaking the script everything melted down for some reason.
Here’s my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterBehavior2 : MonoBehaviour {
private GameObject player, ball;
private bool pickedUp;
void Start ()
{
player = GameObject.Find ("User");;
ball = GameObject.Find ("Ball");
pickedUp = false;
}
void Update ()
{
if (Input.GetKey (KeyCode.E) == true) {
Debug.Log ("Press E");
}
Debug.Log ("Update Works");
/*if (pickedUp == false & Input.GetKeyDown(KeyCode.E)) {
pickedUp = true;
PickedUp ();
}
if (pickedUp = true) {
}*/
}
void PickedUp()
{
ball.transform.SetParent (player.transform);
ball.GetComponent<Rigidbody> ().isKinematic = false;
ball.GetComponent<Rigidbody> ().useGravity = false;
}
}
So I have a Debug.Log in there to ensure the Update function is working, which it is. Then I have a Debug.Log for the GetKey and when pressing that key, there is no output from the Log. Idk what to do at this point and I’m almost certain my code is correct, although I clearly doubt it since it doesn’t work. Please help.