I am trying to implement a turret system which fires arrows at it's target once it collides with the the trigger. here is my code so far
public GameObject Target; private Vector3 direction = Vector3.up; public float speed=10.0f;
} Basically in the if(ts.hit == true) statement, I need code which can project the arrow towards the enemy, the transform.LookAt(Target.transform) is already getting the arrow to face the target without much problems. Thanks
asked Mar 04 '11 at 03:54 PM
A simple way to correct your code could be(I usually use JS) :
Note that I'm using a CharacterController component. Using transform.Translate doesn't detect collisions and I figure you need your projectiles to be aware of those. Or you could use AddForce, but I'm not a big fan of physics.
Also note that SimpleMove will automatically add gravity, if you don't want that for some reason, take a look at ctrl.Move() instead;
Sorry I didn't test the code, but I figure it should work.
answered Mar 04 '11 at 04:06 PM
thanks for the answer, all i had to do was change the direction to Vector3.forward!
answered Mar 05 '11 at 12:45 AM