Can a Vector3 be a variable? I thought so, but I can’t seem to find the correct syntax. How do I make this work?
for (float i = 0 ; i < blockX; i++)
{
Vector3 rowX = (i,0,0); //error on this line
Rigidbody instance = Instantiate (block,rowX, 0 );
}
This gives me the error: error CS1026: Unexpected symbol ,', expecting
)’
I have also tried skipping the declaration and just putting:
Rigidbody instance = Instantiate (block,Vector3(i,0,0),0);
That gives me more errors though.
Vector3 isn’t a variable, it’s a struct. You need create it instead of just assigning it, you were missing “new Vector3”
for (float i = 0 ; i < blockX; i++)
{
Vector3 rowX = new Vector3 (i,0,0); //error on this line
Rigidbody instance = Instantiate (block,rowX, 0 );
}
Lunar9
3
When I try this with my code,
float posX;
float posY;
Vector2 playerPosition = new Vector2(posX, posY); //error on this line.
i get the error:
Assets\Player.cs(18,48): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Player.posY'
BTW I use Unity and I am a new porogrammer.