x


Spawn a Shield Faceing Forward?

Hi everyone. I have a robot that uses a shield to block fireballs. But when i press the space button, it faces the same way everytime, so i end up with a sideways shield. I have attached the code as well. Any help is appreciated. Thanks, -Alias

function Update ()
{
    if(Input.GetButtonDown("Jump"))
    {
        var bullit = Instantiate(bullitPrefab, transform.Find("Spawnpoint").transform.position, Quaternion.identity); //transform.position 

        bullit.tag = "wormprojectile"; 
    }
}
more ▼

asked Jul 03 '10 at 04:44 PM

Aliasmk gravatar image

Aliasmk
32 10 10 18

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Never Mind, I figured it out, i just needed to change "quaternion.identity" to "transform.rotation". Thanks anyway!

more ▼

answered Jul 03 '10 at 09:46 PM

Aliasmk gravatar image

Aliasmk
32 10 10 18

In that case, mark your answer as solved so we don't get the question popping up weekly :)

Jul 04 '10 at 10:08 AM Mike 3
(comments are locked)
10|3000 characters needed characters left

You could use something like this:

var spawnPoint = transform.Find("Spawnpoint");
var bullit = Instantiate(bullitPrefab, spawnPoint.position + spawnPoint.forward * distanceFromSpawn, spawnPoint.rotation);

distanceFromSpawn is a float which is how far away you want it, if you want it at the spawnpoint's positionm just remove the spawnPoint.forward * distanceFromSpawn

more ▼

answered Jul 03 '10 at 05:51 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

Thanks for your reply. So i just paste it into the var section? I did that, but its giving me errors. Sorry, im new to scripting. Thanks

Jul 03 '10 at 09:10 PM Aliasmk
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5076
x440
x21

asked: Jul 03 '10 at 04:44 PM

Seen: 834 times

Last Updated: Jul 03 '10 at 05:52 PM