First of all, i'm just a beginner, but I tried do create a wall jump system in my 3D game :) ;
perhaps, it doesnt work, because I think the issue is on line 65 (I added commentary).
If someone better than me may help me please.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Saut : MonoBehaviour {

private Vector3 moveVector;
private Vector3 lastMove;
private float speed = 8;
private float jumpforce = 8;
private float gravity = 25;
private float verticalVelocity;
private CharacterController controller;


public KeyCode ToucheSaut;

// Update is called once per frame

private void Start(){
controller = GetComponent();


private void Update(){
moveVector = Vector3.zero;

// Pour se d├ęplacer
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
moveVector.x = horizontalInput;
moveVector.z = verticalInput;

// verticalVelocity = -1; It attract us below when player is grounded
verticalVelocity = 0;

verticalVelocity = jumpforce;
verticalVelocity -= gravity * Time.deltaTime;
moveVector = lastMove;

moveVector.y = 0;
moveVector *= speed;
moveVector.y = verticalVelocity;

// Issue in relation with "Pour se d├ęplacer" :
controller.Move(moveVector * Time.deltaTime);
lastMove = moveVector;


private void OnControllerColliderHit(ControllerColliderHit hit){
if(!controller.isGrounded && hit.normal.y < 0.1f){

Debug.DrawRay(hit.point,hit.normal,Color.red, 1.25f);
verticalVelocity = jumpforce;
moveVector = hit.normal * speed;

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

How to report your problem productively in the Unity3D forums:


How to understand compiler and other errors and even fix them yourself:


Beyond that, to help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

You could also just display various important quantities in UI Text elements to watch them change as you playtest.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.

Here's an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:


You said it "doesn't work", but that doesn't really tell us anything. When you want very specific help, you need to describe your issue with the same level of detail. Also, don't post code in a difficult to read fashion. Take a look at how other people are doing it first. When you make it hard for people to help you, you're unlikely to get any help.

But I just want to point out, if you are new to Unity you should not be starting with Unity version 4.0. That version is about a decade old.