So there is a giant enemy on my game. This code is at my Player. When Giant Enemy hits, bePushed is becoming true. I checked that part is working. And in if, bePushed=false is working to. But my character is not moving. How can i fix that? Please help me.
Hi,
you have some syntax errors:
It is bool not Bool, Start() not start
rb = GetComponent(); not with ==
After that, use AddForce into FixedUpdate() not Update.
And i think the player wont stop when bePushed = false… When you add a force, its continuous. If you want the player stops you have to slowdown/stop its velocity…
void FixedUpdate()
{
if (bePushed)
{
rb.AddForce(-transform.forward* 100);
bePushed=false;
}
}
But it didnt work. Could it be because of something on rigidbody?