#I did not edit it. Can you confirm the

1 messages · Page 1 of 1 (latest)

strange hull
#

Yeah, debugging via logs. The Jump gets triggered, I'm grounded..

#

trying to share the code..

#
private void Update()
    {
        Movement();
    }

    private void Movement()
    {
        m_moveVelocity.x = m_inputMovement.x * m_moveSpeed * Time.deltaTime;
        m_moveVelocity.z = m_inputMovement.y * m_moveSpeed * Time.deltaTime;
        m_moveVelocity.y =  -m_gravity * Time.deltaTime; // Apply gravity.
        
        var moveVelocityInWorldSpace = transform.TransformDirection(m_moveVelocity);
        
        m_characterController.Move(moveVelocityInWorldSpace);
    }

    private void Jump()
    {
        if (m_characterController.isGrounded)
        {
            m_moveVelocity.y += Mathf.Sqrt(m_jumpForce * 2 * -m_gravity);;
        }
    }

eternal jacinth
#

It doesnt look like you're running the Jump() function

strange hull
#

The Jump is triggered by Space

#

(new Input System)

eternal jacinth
#

Can I see that code?

strange hull
#

m_inputControls.Character.Jump.performed += e => Jump(); (in Awake)

#
using System;
using UnityEngine;

public class PlayerMovement2 : MonoBehaviour
{
    [SerializeField, NotNull] 
    private CharacterController m_characterController = null;
    
    [SerializeField, Tooltip("Move speed each frame in meters.")]
    private float m_moveSpeed = 5f;

    [SerializeField] 
    private float m_gravity = 20;

    [SerializeField] 
    private float m_jumpForce = 30;
    
    private Vector2 m_inputMovement;
    private Vector3 m_mouseInput; // TODO: temp 
    public Vector2 MouseInput => m_mouseInput; // TODO: temp

    private InputControls m_inputControls;
    private Vector3 m_moveVelocity = Vector3.zero;
    private float m_jumpVelocity;

    private void Awake()
    {
        m_inputControls = new InputControls();
        m_inputControls.Enable();
        m_inputControls.Character.Movement.performed += e => m_inputMovement = e.ReadValue<Vector2>(); // Normalized
        m_inputControls.Character.View.performed += e => m_mouseInput = e.ReadValue<Vector2>(); // delta
        m_inputControls.Character.Jump.performed += e => Jump();
    }

    private void Update()
    {
        Movement();
    }

    private void Movement()
    {
        m_moveVelocity.x = m_inputMovement.x * m_moveSpeed * Time.deltaTime;
        m_moveVelocity.z = m_inputMovement.y * m_moveSpeed * Time.deltaTime;
        m_moveVelocity.y =  -m_gravity * Time.deltaTime; // Apply gravity.
        
        var moveVelocityInWorldSpace = transform.TransformDirection(m_moveVelocity);
        
        m_characterController.Move(moveVelocityInWorldSpace);
    }

    private void Jump()
    {
        if (m_characterController.isGrounded)
        {
            m_moveVelocity.y += Mathf.Sqrt(m_jumpForce * 2 * -m_gravity);;
        }
    }
}
#

this is the whole class

eternal jacinth
#

Try to replace m_moveVelocity.y += with m_moveVelocity.y =

strange hull
#

Does nothing..

#

oh, wait a second!!!

#

OK, not working

eternal jacinth
#

Try to change m_gravity to a negative number like -10

strange hull
#

tried, not working

#

I fly upwards when changed..

#

because I apply gravity each frame in Movement() method

eternal jacinth
#

Lower the jump height to like 2

strange hull
#

I tried numbers from -20k to 20k ..

eternal jacinth
#

I believe I use numbers like 2-3 jump height and -5 to -10 gravity

strange hull
#

sure, me too, I was just curious

eternal jacinth
strange hull
#

Basically the m_moveVelocity.y += Mathf.Sqrt(m_jumpForce * 2 * -m_gravity);; does nothing

#

ok

eternal jacinth
#

Remove the extra semi-colon on that line

#

I need to go and I've been on my phone so I haven't been able to really read your code, sorry. Hopefully you get it working soon though

strange hull
#

don't worry about the semicolon, does nothing, typo.. no probs