- Home /
This question was
closed Aug 08, 2017 at 05:47 AM by
wolve3000 for the following reason:
Solved
Question by
wolve3000 · Aug 07, 2017 at 02:26 AM ·
collisioncolliderrigidbody2d
Player appears on top of an Kinematic object or underneath it when walking forward.
Hello Helpers
I am trying to replicate Mario game. Player has dynamic rigidbody. I am using GetAxisRaw to move forward. following is the code:
void Update () {
if (!isDead)
{
if (facingRight)
transform.localScale = new Vector3(1, 1, 1);
else
transform.localScale = new Vector3(-1, 1, 1);
float move = Input.GetAxisRaw("Horizontal");
transform.position = new Vector2(transform.position.x + move * Time.deltaTime * walkSpeed, transform.position.y);
}
}
sometime Player can go under an object if it keep moving forward. sometime it appears on top of an object. Please see image below.
I also want player hit the flag and fall down just like real Mario game does, but so far I am having some troubles figuring out.
Can anyone helps? Thank you!
mariopng.png
(23.6 kB)
Comment