- Home /
Question by
Tabioca · Jun 26, 2014 at 09:27 PM ·
2d2d-platformerwalljump
2D Wall Jump Problem
Hi i want create a wall jump like Super Meat Boy. How i can do? This is the script for the movement of the player:
using UnityEngine;
using System.Collections;
public class Personaggio : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;
bool crouch = false;
bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public float jumpForce = 700f;
public float jumpPushForce = 10f;
void Start () {
anim = GetComponent<Animator>();
}
void FixedUpdate () {
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
anim.SetBool("Ground", grounded);
anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);
float move = Input.GetAxis ("Horizontal");
anim.SetFloat("Speed", Mathf.Abs (move));
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D.velocity.y);
if(move > 0 &&!facingRight){
Flip ();
}
else if(move < 0 && facingRight){
Flip ();
}
}
void Update()
{
if(grounded && Input.GetButtonDown("Jump"))
{
anim.SetBool("Ground", false);
rigidbody2D.AddForce(new Vector2(0, jumpForce));
}
}
void Flip(){
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
Comment
I have already done so that if the player performs a wall jump, it may rerun a jump but what I would like to create is to make sure that if the player jumps against the wall and once again press the spacebar makes the jump against the wall the ports on the opposite side of the wall and not allowing another leap as happens in super meat boy