Hello Guys
I have a problem with addforce… I want to Instantiate a gameobject and then move it forward and this is my code but the gameobject doesn’t move forward :
using UnityEngine;
using System.Collections;
using System.Timers;
public class CreatingBullets : MonoBehaviour {
public GameObject MyGameObject;
public bool Created = false;
public float Power;
void Update()
{
if(Input.touchCount == 1)
{
if(Created == false)
{
Instantiate(MyGameObject, transform.position, transform.rotation);
MyGameObject.rigidbody.AddForce(transform.forward * Power);
Created = true;
StartCoroutine(WatingVoid());
}
}
}
IEnumerator WatingVoid()
{
yield return new WaitForSeconds(1);
Created = false;
}
}
thanks a lot…