# solution for a walljump?

It seems i can not find a clear answer anywhere on this topic, I’ve been searching for hours.
Anyways I’m looking for a simple walljump in a “arc” manner see picture below:

I figured I would be able to use Forcemode2D.Impulse but i am unfamiliar with it.
but all ive been able to achieve with it is my character going straight up.
if someone can enlighten a young grasshopper it would be very much appreciated, it would make my day thank you.
here is my code:

``````using UnityEngine;
using System.Collections;

public class walljumptestinh : MonoBehaviour
{
public float speed = 10, jumpVelocity = 10;
public bool canMoveInAir = true;
Transform myTrans;
Transform tagGround;
Transform tagWall;
Rigidbody2D myBody;
public bool isGrounded = false;
public bool istouching = false;
float hInput = 0;

void Start ()
{
myBody = this.rigidbody2D;
myTrans = this.transform;
tagGround = GameObject.Find (this.name + "isground").transform;
tagWall = GameObject.Find (this.name + "touchwall").transform;
}

void FixedUpdate ()
{
istouching = Physics2D.Linecast (myTrans.position, tagWall.position, wallmask);
isGrounded = Physics2D.Linecast (myTrans.position, tagGround.position, playerMask);
Move (hInput);
}

void Move(float horizonalInput)
{
if(!canMoveInAir && !isGrounded)
return;

Vector2 moveVel = myBody.velocity;
moveVel.x = horizonalInput * speed;
myBody.velocity = moveVel;
}

public void Jump()
{
if (isGrounded) {

myBody.velocity += jumpVelocity * Vector2.up;
}
Vector2 force = new Vector2 (-20f, 10f);
if (istouching) {
}

}

public void StartMoving(float horizonalInput)
{
hInput = horizonalInput;
}
}
``````

If you have a real physics environment, this will be more work than it’s worth to use AddForce. You will constantly have to calculate the point at witch you will need to apply opposing force to push back along the X axis. What I would do instead, is check out this question I recently discussed about how to map out the trajectory of a jump:

Simply map it out as if it were in normal XY relation, then translate the generated coordinates so that you have that path to follow, and use MoveTo to navigate the “path” of coordinates.

Basically the topic/question that I mention above is really to just draw an arc of what a jump would be if you were using AddForce… so it SHOULD fit perfectly in your case to draw that path you want… just rotate the whole path 90 degrees after you draw it!

Hope that helps!