I Am trying to move the ball when the key "I" is pressed when making contact with the players, this is my code which is not working
using UnityEngine;
using System.Collections;
public class KickForce : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter (Collision col) {
if(col.gameObject.tag == "Player")
{
if (Input.GetKey ("i")) {
transform.Translate(Vector3.right * Time.deltaTime * 10);
}
}
}
}
↧