Forum begins after the advertisement:


[Part 1] Unable to jump

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16295
    Yusuke Hanayama
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    I did everything exactly like in the first video of the tutorial series. Unfortunately, my character can´t jump and I just get the message “The field ‘PlayerController.jumpForce’ is set, but its value is never used. I linked my code here: Player Controller Code

    #16297
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Yusuke, you’ll need to post your code in text here. We can’t see the image you posted.

    #16299
    Yusuke Hanayama
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    Oh sorry I’m pretty new to this. Anyways, heres my code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class PlayerController : MonoBehaviour
    {
        [Header("Horizontal Movement Settings")]
        private Rigidbody2D rb;
      	
        [SerializeField] private float walkspeed = 10;
       
        private float xAxis;
    
        private float jumpForce = 10;
    
        // Start is called before the first frame update
        void Start()
        {
            rb = GetComponent<Rigidbody2D>();
        }
    
        // Update is called once per frame
        void Update()
        {
           GetInputs(); 
           Move();
        }
    
        void GetInputs()
        {
            xAxis = Input.GetAxisRaw("Horizontal");
        }
        
        private void Move()
        {
           rb.velocity = new Vector2(walkspeed * xAxis, rb.velocity.y);
        }
    
        }
    #16302
    Chloe Lim
    Level 9
    Moderator
    Helpful?
    Up
    1
    ::

    Hi, you need to add Jump() to your Update function
    I dont see the script you sent having the jump function, if the problem still persist, do send it here as well and we could further check what could be causing the issue

    has upvoted this post.
    #16303
    Yusuke Hanayama
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    Ok i’ll try it out! Thanks for the advice!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: