- Home /
Question by
hledward7 · Mar 10, 2021 at 04:27 AM ·
ontriggerentertransform.position
isit posible to remove transform.parent quickly? in the OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D coll)
{
anim.SetBool("isJumping", false);
if (coll.gameObject.CompareTag("movingplatform"))
{
this.transform.parent = coll.transform;
}
if (Input.GetButtonDown("Jump") && grounded)
{
this.transform.parent = null;
anim.SetBool("isJumping", true);
if (rb.velocity.y == 0)
{
rb.velocity = Vector2.up * JumpForce;
}
}
}
void OnTriggerExit2D(Collider2D coll)
{
if (coll.gameObject.CompareTag("movingplatform"))
this.transform.parent = null;
}
Comment
i don't see any delay in code , what do you mean by quickly ?
the delay when i pressing spacebar to jump in the moving platform i need to press a few time able to jump... because player is inside the movingplatform
Answer by GeroNL · Mar 10, 2021 at 09:15 PM
Why do you must jump when it is juts in trigger? you can not do jump except in it?
The jump not response quickly maybe cause the trigger is not get call on the time (is not like update that get call frame to frame). why you do not make a jump in update?
Your answer
Follow this Question
Related Questions
My "Lava " script doesnt work 2 Answers
How to make game like Hoops Stack 1 Answer
Object moves X units over Y time 1 Answer