- Home /
Question by
Shiro_Rin · Oct 20, 2015 at 07:19 PM ·
2drigidbody2daddforce
Rigidbody2d addforce isn't moving character
public void Fire(){
IsShot = true;
BasePower += MeterPower;
Instantiate (Player, CannonEnd.transform.position, CannonEnd.transform.rotation);
Player.GetComponent<Rigidbody2D>().AddForce (Vector2.right * BasePower);
}
Keep in mind I have variables for base power that are set to 100, and meterpower which is set to any number higher than 1. Which I try to move the object , it won't move.
Comment
Best Answer
Answer by Shiro_Rin · Oct 20, 2015 at 08:06 PM
I figured out my problem, I was getting the component on Player, but when it is instantiated, it's now a clone and the code doesn't reference it anymore. So, I use GameObject.FindGameObjectWithTag("Player").GetComponent ().AddForce (Vector2.right * BasePower); It now works great :)