- Home /
Robot turrets move and fire
Hey I am making a game where you are a robot, I want the legs to move the body while the top follows the mouse and fires bullets. I have the moving and rotating down all I need is help with the bullets flying from the turret, instead of the legs, I put script on the turrets and made them fire but its still coming from the legs.
Answer by duck · Apr 21, 2010 at 10:01 AM
It sounds like you simply need to either raise the position of the bullet's starting position, or - if your turrets are a separate gameObject, use the turret's position instead of the legs. (Presumably your script is on the "legs" gameobject, and the rotating turret is a child object of the legs?...).
Eg - Instead of:
var bullet = Instantiate( bulletPrefab, transform.position, turret.rotation);
You could either have:
var bullet = Instantiate( bulletPrefab, turret.position, turret.rotation);
Or:
// bullets start 2 units higher:
var bulletPos = transform.position + Vector3.up * 2;
var bullet = Instantiate( bulletPrefab, bulletPos, turret.rotation);
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
get name of child object script is attached to? 1 Answer
Is FindGameObjectWithTag() too heavy on resources for 50 objects? 0 Answers
Using script's method from all of the gameobjects that has that script 2 Answers
Unity Editor Scripts: GameObject Added / Removed Event? 1 Answer