#Jumping deos not work

1 messages · Page 1 of 1 (latest)

finite pier
#

Hi i was trying to make a game but i cannot find a tutorial that works with my code to implement the jump mechanic
here is the code:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{

private Animator anim;
private CharacterController controller;

public float speed = 600.0f;
public float turnSpeed = 400.0f;
private Vector3 moveDirection = Vector3.zero;
public float gravity = 20.0f;

void Start()
{
    controller = GetComponent<CharacterController>();
    anim = gameObject.GetComponentInChildren<Animator>();
}

void Update()
{
    if (Input.GetKey("w"))
    {
        anim.SetInteger("AnimationPar", 1);
    }
    else
    {
        anim.SetInteger("AnimationPar", 0);
    }

    if (controller.isGrounded)
    {
        moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;
    }

    float turn = Input.GetAxis("Horizontal");
    transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
    controller.Move(moveDirection * Time.deltaTime);
    moveDirection.y -= gravity * Time.deltaTime;
}

}

#

btw this code doesn't have the jump script cuz i deleted it since it didn't worked

finite pier
#

yea but that ttorial is for a first person game and i am trying to make a 3rd person game i didn't specified that srry

fossil crow
#

As a sidenote: I don't know how you possibly expect any help when you don't show the problematic code. You can't say "jumping doesn't work" and then show only the working code, what does that remotely achieve?

#

It's like going to a mechanic saying "my car doesn't work!" But then pointing to your friend's car that does work. How can the mechanic help with your broken car if you don't show the broken car

finite pier