Hi there,
I have followed a tutorial online to have a turret following my characters position and shooting in that direct, however fro some reason my stock characters “focal” point is pretty misaligned? I have tried using the character head as a target for the turret, however it refuses to even move in that case. I have tried adding an empty gameObject as a child of my character and using that as the target but again no luck with the turret giving any reaction. You can see from my screenshot below how the turret works:
[24121-screen+shot+2014-03-23+at+16.47.10.png|24121]
(as a side note, my player is also slanted for some reason?
Here is the code I am using for the turret movement:
var target : Transform;
var turret : Transform;
var damp = 1.0;
var bullet : Transform;
var bulletSpawn : Transform;
var timer = 0.0;
function OnTriggerStay (other : Collider)
{
timer+= Time.deltaTime;
if (other.transform == target)
{
turret.transform.LookAt(target);
if (timer>0.5)
{
Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation);
timer = 0.0;
}
}
}
Many thanks!