- Home /
Question by
jamesera2511 · Nov 30, 2020 at 06:07 PM ·
movementrigidbodyrigidbody-collisionrigidbody physicswall jump
Wall jump, jump movement not working
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class WallJump : MonoBehaviour {
public float BoostForce = 20f;
public bool isOnWall = false;
PlayerMovement PlayerMove;
// Start is called before the first frame update
void Start()
{
PlayerMove = GetComponent<PlayerMovement>();
}
void OnCollisionEnter (Collision col)
{
if (col.gameObject.CompareTag("Obstacle") && PlayerMove.isGrounded == false)
{
isOnWall = true;
if (Input.GetKey("space"))
{
transform.Translate(Vector3.up * BoostForce);
}
}
}
private void OnCollisionExit(Collision col)
{
if (col.gameObject.CompareTag("Obstacle")&& PlayerMove.isGrounded == true)
{
isOnWall = false;
transform.Translate(Vector3.up * BoostForce);
}
}
}
Beginner here, I'm trying to make a simple walljump movement but I somehow can't jump from the wall. I tied various ways to make my player move like addforce. new vector etc... but somehow it doesn't work. Here's my script
P.S My PlayerMove is my playercontroller
Comment