Game Development Reference
In-Depth Information
Time.deltaTime, 0.0f, 0.0f));
}
else
{
transform.Translate(new Vector3((walkingSpeed * -1.0f)
* Time.deltaTime, 0.0f, 0.0f));
}
}
public void switchDirections()
{
// Swap the direction to be the opposite of whatever it
// currently is
walkingLeft = !walkingLeft;
// Update the orientation of the Enemy's material to match
//the new walking direction
updateVisualWalkOrientation();
}
void updateVisualWalkOrientation()
{
Vector3 localScale = transform.localScale;
if(walkingLeft)
{
if(localScale.x> 0.0f)
{
localScale.x = localScale.x * -1.0f;
transform.localScale = localScale;
}
}
else
{
if(localScale.x< 0.0f)
{
localScale.x = localScale.x * -1.0f;
transform.localScale = localScale;
}
}
}
}
 
Search WWH ::




Custom Search