Howdy.
I have an Zombeh that I am shooting at (instantiated bullet prefab)
But when the bullet hits the zombehs, they just spin out and start floating away. Gravity is turned on. I need to keep the rigidbody on them for collison and stuff, but how would I keep these guys still why being shot.
Let me rephrase that. I want them to get pushed back a tiny bit when they are hit, but these guys are just flying away and spinning.
I was thinking I could change the rigidbodys to kinematic and then handle the movement through rigidbody scripting.
Here is my script:
static var player : GameObject;
var tplayer : Transform;
var speed : float = 1;
function Start ()
{
player = GameObject.FindGameObjectWithTag("Player");
}
function Update()
{
//Debug.Log ("player is close");
var delta = player.transform.position - transform.position;
delta.Normalize();
var moveSpeed = speed * Time.deltaTime;
transform.position = transform.position + (delta * moveSpeed);
transform.LookAt(tplayer);
}
The collision with the bullet and zombie is handled in another one of my scripts.
Also, How would i make it so that these guys don’t rotate up towards my player when they get close? I cant restrict rotation on the Y axis or else they wouldn’t be able to rotate correctly.