This is all in Unity, with C#.
I have attached a script to my player that should destroy a TreeGroup
(as in a forest) whenever I press 'Q' and instantiate one when I press 'E'.
Here is the code:
using UnityEngine;
using System.Collections;
public class DisableTrees : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.A)) {
//Disable Trees on A Keypress
Debug.Log("Trees Disabled!");
}
if (Input.GetKeyDown (KeyCode.E)) {
//Enable Trees on E Keypress
Debug.Log("Trees Enabled!");
}
}
}
How do I access and find my 'TreeGroup' object group while script not being attached to 'TreeGroup' but my character instead and then Destroy on Q Keypress? And how do I Instantiate it?
No comments:
Post a Comment