- Home /
Setting Spawn Rotation correct
I have the following script spawning a domino on my grid, but it is spawning it face down. How would I go about changing the rotation so that it spawns standing up?
void Build (){
ray= Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray,out hit, 1000)){
hitPoint = hit.transform.position + hit.normal;
Instantiate(currentBlock, hitPoint, Quaternion.identity);
}
}
Its spawning face down I need it to spawn standing up so it can bee nocked over.
Answer by Em3rgency · Jun 26, 2013 at 04:31 PM
Read up on Quaternion and change Quaternion.identity accordingly. Thats the part of instantiate that deals with rotation.
EDIT: Also, when you will rotate it to face up, it will probably be half-way through your grid. So you will also need to raise its y axis position by (Y size)/2.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Object Spawning Too Low 0 Answers
Spawning off size blocks 1 Answer
Distribute terrain in zones 3 Answers
Spawning A Grid Of Cubes 2 Answers