Question by
KnightNobody · Jul 19, 2016 at 01:32 PM ·
c#rigidbody2dforcefunctions
Problem with force movement when calling from another scripts
So I have 2 scripts one called SheepManager and one called Sheep. When I call the Jump() function from withing the Sheep function it functions and the force get's applied. When I cal it from SheepManager the function gets called but no force is being applied. The currentSheep variable is of type Sheep and has the correct reference.
if (Input.GetKey(KeyCode.Space)) { if (currentSheep.Jump() == true && currentSheepID < sheepPool.Count) currentSheepID++; else currentSheepID = 0; }
public bool Jump()
{
if (!jumped)
{
rigb.velocity = Vector2.zero;
rigb.AddForce(jumpDir * JumpForce, ForceMode2D.Impulse);
return true;
}
return false;
}
Comment