The question is answered, right answer was accepted
Instantiate a GameObject randomly between 2 rotation values
Hello
I'm trying to spawn GameObjects (walls) on their original rotation (0) or randomly turned 180 too. this is what I tried:
{
Vector3 startPos = transform.position; // get the current spawner position
Quaternion spawnRotation[0] = Quaternion.identity; // this quaternion corresponds to no rotation
Quaternion spawnRotation[1] = Quaternion.Euler(0, 0, 180); // 180 turned value
Instantiate (wall, startPos, spawnRotation[Random.Range(0,2)]); // what I thought would work to Instantiate my wall at startPos with a rotation random between spawnRotation 0 and 1
}
But I have these Red Alerts :)
anderror CS0650: Syntax error, bad array, declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type
error CS1525: Unexpected symbol
=', expecting
)',,', or
;'
Starting to learn C#, Can someone tell me what i'm doing technically wrong here please ? Thx
Answer by krousty_bat · Mar 07, 2016 at 06:58 PM
Solutions available here : http://forum.unity3d.com/threads/solved-instantiate-a-gameobject-randomly-between-2-rotation-values.390282/
Thx.
Follow this Question
Related Questions
Random position of asteroids -- Random not randomizing? 1 Answer
Instantiate a prefab at three specific x positions 0 Answers
Set Instanatiated Object's Rotation Towards Player 1 Answer
Why do I keep getting 'The object you want to instantiate is null' warning? 1 Answer
LevelGenerator after Checkpoint Respawn Not Aligning Tiles Properly 1 Answer