I have implemented jumping according to your method, but there is a situation where jumping and teleportation cannot coexist, and only one function can be implemented separately. May I ask how to solve this problem and can I provide some help?
Why does it not work together, can you please elaborate? Make sure you set "Attempting to move" to "Immediate" on your locomotion provider, this might be the issue why you cant jump after teleportation.
Suggestion - could you please explain using Asset Bundles with Normcore? (Not addressables). It's very hard to understand their documentation on this subject.
I found that this script got me most of the way there but there was some problems with the jump button not always working. I suspect that this may be due to the constant setting of the playerVelocity.y to a negative value which can momentarily cause the player controller to slip through the ground making .isGrounded false. The only thing that's missing is to have a separate global boolean that gets set to true within the if statement scope starting at line 28, having that boolean set to false upon invoking the jump function, and detecting whether or not this boolean is true instead of the conditional on line 22. Me personally, I wrote this code: /////////////////////////////////////////////////////////////// using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class advancedMovement : MonoBehaviour {
public InputActionReference jumpButton = null; public CharacterController charController; public float jumpHeight; private float gravityValue = -9.81f; private Vector3 playerVelocity; public bool jumpButtonReleased; private bool isTouchingGround; // Start is called before the first frame update void Start() { jumpButtonReleased = true; } // Update is called once per frame void Update() {
worked amazingly, thank you
Here's a suggestion for a video. Crouch in VR or Seated Mode
I have implemented jumping according to your method, but there is a situation where jumping and teleportation cannot coexist, and only one function can be implemented separately. May I ask how to solve this problem and can I provide some help?
Why does it not work together, can you please elaborate? Make sure you set "Attempting to move" to "Immediate" on your locomotion provider, this might be the issue why you cant jump after teleportation.
For some reason this doesn't seem to work unless my character is walking, trying to jump in place causes the jump to be very small
Suggestion - could you please explain using Asset Bundles with Normcore? (Not addressables). It's very hard to understand their documentation on this subject.
Could you please specify what you mean? I can't find any documentation on Asset Bundles from Normcore.
Will it just appear in store and is there any licenses someone needs to fill what's the improvement time?.
I found that this script got me most of the way there but there was some problems with the jump button not always working. I suspect that this may be due to the constant setting of the playerVelocity.y to a negative value which can momentarily cause the player controller to slip through the ground making .isGrounded false.
The only thing that's missing is to have a separate global boolean that gets set to true within the if statement scope starting at line 28, having that boolean set to false upon invoking the jump function, and detecting whether or not this boolean is true instead of the conditional on line 22. Me personally, I wrote this code:
///////////////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class advancedMovement : MonoBehaviour
{
public InputActionReference jumpButton = null;
public CharacterController charController;
public float jumpHeight;
private float gravityValue = -9.81f;
private Vector3 playerVelocity;
public bool jumpButtonReleased;
private bool isTouchingGround;
// Start is called before the first frame update
void Start()
{
jumpButtonReleased = true;
}
// Update is called once per frame
void Update()
{
playerVelocity.y += gravityValue * Time.deltaTime;
charController.Move(playerVelocity * Time.deltaTime);
if (charController.isGrounded && playerVelocity.y < 0) {
playerVelocity.y = 0f;
isTouchingGround = true;
}
float jumpVal = jumpButton.action.ReadValue();
if (jumpVal > 0 && jumpButtonReleased == true) {
jumpButtonReleased = false;
Jump();
isTouchingGround = false;
} else if (jumpVal == 0){
jumpButtonReleased = true;
}
}
public void Jump() {
if (isTouchingGround == false) {
return;
}
playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
}
}
/////////////////////////////////////////////////////
It differs in how it detects input from the custom button event when compared to the video.
Nice, works great for me.