![]() ![]() ![]() Thank you in advance for any help you can offer. Whenever Im going upwards on a Slope, if I jump it looks like I didnt really jump and Im still walking, but if I stop walking or go downwards it will go higher for the remaining jump height. JumpVector.y -= gravity * ltaTime Ĭontroller.Move(jumpVector * ltaTime) Hello, Im building a Character Controller for a 3D Platformer, and Im having a problem with my Jump mechanic. (This is a 2D project) I have a jumping issue where if my character WALKS into an X platform, she wont jump, but when she JUMPS ONTO the X platform, she can perform a jump. JumpVector.y = Mathf.Sqrt(jumpHeight * 2f * gravity) Unity Jumping Issue - Character wont jump if it walks to the platform. Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward Ĭontroller.Move(moveDir.normalized * moveSpeed * ltaTime) Transform.rotation = Quaternion.Euler(0f, angle, 0f) If (moveDirection.magnitude >= 0.1f & groundedPlayer)įloat targetAngle = Mathf.Atan2(moveDirection.x, moveDirection.z) * Mathf.Rad2Deg + įloat angle = Mathf.SmoothDampAngle(, targetAngle, ref turnSmoothVelocity, turnSmoothTime) Drag the Main Camera as a child of the Player gameobject. Change the Center variable on the CharacterController component to X 0, Y 1, Z 0. This will also add the CharacterController component. Vector3 moveDirection = new Vector3(x, 0f, z).normalized Click on the Player gameobject and confirm the Layer is assigned as Player. Public Vector3 jumpVector = Vector3.zero įloat x = Input.GetAxisRaw("Horizontal") Here is the code: public class MovePlayer : MonoBehaviour The main problem with the Character Controller is the ground detection if you try to get funky with some stuff, like having it slide down slopes. It is hard to compare the problems with each way of moving the character. While I understand how the existing code works (after many hours reading about Eulers and Quaternions), unfortunately I can’t figure out how to both keep forward momentum while jumping and allow the player to control their position while in the air. Chosing the right jump and gravity multiplier ratio is important, ect. My code is almost all from Brackey’s 3D movement tutorial with a few small customizations and animation code: (Link to his tutorial: THIRD PERSON MOVEMENT in Unity - YouTube). Can anyone help point out how I can accomplish this? I’ve read several posts on Unity and Stack Overflow and can’t find any similar questions/solutions. I’m trying to have the player continue his/her forward momentum when jumping, and also allow them to control the character while in the air as that’s a common/expected mechanic. ![]() The problem is when the player jumps all forward momentum is lost, the character just jumps straight vertically. I am creating a 3D platformer and have created a character controller that allows the player to run and jump. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |