I am trying to make a script when the player clicks a gameobject then by hiting certain keys can move it around
But I cant figure it out so far I have:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EditScript : MonoBehaviour {
public float x;
public float y;
public bool z;
public bool b;
public Rigidbody r;
void Start () {
r = GetComponent ();
}
void OnCollisionStay(Collision collision) {
if (collision.gameObject.tag == “Player”) {
b = true;
Debug.Log (“Edit();”);
x = Input.GetAxis (“Horizontal”);
y = Input.GetAxis (“Vertical”);
z = Input.GetKeyDown (KeyCode.R);
if (x > 0) {
r.AddRelativeForce (1f, 0f, 0f);
x = 0f;
}
if (y > 0) {
r.AddRelativeForce (1f, 0f, 0f);
}
if (z) {
r.AddRelativeForce (Vector3.forward);
if (!z) {
z = Input.GetKeyDown (KeyCode.C);
if (z) {
}
}
}
}
}
}
It would be helpful if you have a working script