Question by
nu51313932 · Sep 21, 2017 at 07:13 AM ·
physics2djumpingrigidbody.addforce
rigidbody2d.addforce do not stop the force when rigid2d.iskenemetic = true;
Example: When I addforce to make it jump and instant use rigid2d.iskenemetic = true; the object still move upward.
//CLIMB LADDER
public bool OnLadder;
public Vector3 v3;
public float climbspeed;
bool climbing;
private Transform treeLine;
bool canClimb;
void Start()
{
rigid2d = GetComponent<Rigidbody2D>();
}
void Update(){
if (canClimb)
{
if ( Input.GetKey(KeyCode.W))
{
transform.Translate(Vector2.up * 1.0f * Time.deltaTime);
rigid2d.isKinematic = true;
}else
if (Input.GetKey(KeyCode.S) && rigid2d.isKinematic == true)
{
transform.Translate(Vector2.down * 0.3f * Time.deltaTime);
rigid2d.isKinematic = true;
}
if (canClimb == false)
{
rigid2d.isKinematic = false;
}
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "LadderStart")
{
canClimb = true;
if (Input.GetKey(KeyCode.W))
{
rigid2d.isKinematic = true;
}
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "LadderStart")
{
canClimb = false;
rigid2d.isKinematic = false;
}
}
Comment