How Can I Make A Wall jump Code?
I am very new to unity and am currently making a very simple game. so far its a game where a cube can move around and jump, i set up two walls and wanted to create a wall jump mechanic but i was totally lost. If you can help, that would be great. If this helps here is my jump script:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
public class Jump : MonoBehaviour
{
public Vector3 jump;
public float jumpForce = 2.0f;
public bool isGrounded;
Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
jump = new Vector3(0.0f, 2.0f, 0.0f);
}
void OnCollisionStay()
{
isGrounded = true;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
rb.AddForce(jump * jumpForce, ForceMode.Impulse);
isGrounded = false;
}
}
}
`
Treat walls like another type of ground, with less priority than the actual ground. You've already got a basic grounded system for deter$$anonymous$$ing jumps, so the next step will be to create a way for that character to know when they are within a valid wall jump zone. You can probably do this most easily by either making trigger colliders for walls or updating your OnCollisionStay
to check that it's touching an object flagged as a "Wall".
Answer by PenguinXP · Feb 22, 2018 at 09:37 PM
Ok, thank you! i just tried it and im on the right track! i still need to fix somethings bit im getting there
Your answer
Follow this Question
Related Questions
align player to object location in C#? 0 Answers
Swapping player's controls in game (2D) 1 Answer
I want to add some Velocity controll to my CharacterController 1 Answer
how to move only one object ? 1 Answer
fps script not working 1 Answer