Question by
jenielsen · Aug 30, 2015 at 04:06 PM ·
error messagestuck
getting the error CS0201 and i cant fix it.
so i have started making games from this tutorial book i found online. it is a bit old i will admit. but in the following code i keep getting the error CS0201 in the line poi == null; and i dont know what is wrong.
void FixedUpdate()
{
Vector3 destination;
//if there is no poi, return to p: [0,0,0]
if (poi == null)
{
destination = Vector3.zero;
} else
{
//get the position of the poi
destination = poi.transform.position;
//if the poi is a projectile, check to see if it is at rest
if (poi.tag == "Projectile")
{
//if it is sleeping (that is, not moving)
if ( poi.rigidbody.IsSleeping() )
{
//return to default view
poi == null;
//in the next update
return;
}
}
}
im copying this from a book but i cant find the code on the internet.
Comment
Best Answer
Answer by Dave-Carlile · Aug 30, 2015 at 04:07 PM
=
is the assignment operator, ==
is the comparison operator.
When you say poi == null
you're trying to compare poi to null, which you can only do in a conditional statement such as if
or while
. To assign null to poi you need to use the assignment operator, so poi = null;
.
Answer by jenielsen · Aug 31, 2015 at 02:13 PM
thanks that worked, strange that is in the book ._. now i know that to another time :)