#jumping and how to not lose one's sanity doing it
1 messages · Page 1 of 1 (latest)
sorry
this is probably easier
i was saying that i was making a bool in the movement class to reference to the animator class that the player is jumping
unless that wasnt what you were saying
ive tried bools, but now a float measuring height seems to be my only option
a bool would not "reference" the animation class
it's just a bool
you should have the player class reference the animation class
already did
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;
public class UpdatedPlayerMovement : MonoBehaviour
{
//input fields
private Controls controls;
private InputAction move;
//movement fields
private Rigidbody rb;
[SerializeField]
private float movementForce = 1;
[SerializeField]
private float JumpingForce = 5f;
[SerializeField]
private float maxSpeed = 5f;
private Vector3 forceDirection = Vector3.zero;
// sprinting items
public bool IsSprinting;
public float walkingSpeed;
public float sprintingSpeed;
private float movingSpeed;
[SerializeField]
private Camera playerCamera;
private Animator animator;
// ui assets
public TextMeshProUGUI text_speed;
oh, I thought you had a separate class that was doing animation
you just have an Animator on there
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonAnimation : MonoBehaviour
{
private Animator animator;
private Rigidbody rb;
public float maxHeight;
public float maxSpeed;
// Start is called before the first frame update
void Start()
{
animator = this.GetComponent<Animator>();
rb = this.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
animator.SetFloat("speed", rb.velocity.magnitude / maxSpeed);
animator.SetFloat("height", rb.velocity.magnitude / maxSpeed);
}
}
i do
but you aren't referencing it here
you're referencing the animator
yes, i am
so is it simply just working with the animator in UpdatedCharacterMovement, or...
someone needs to tell the animator to play the jump animation
my suggestion was for the ThirdPersonAnimation class to do that. UpdatedPlayerMovement would just tell it "hey, we just jumped", so that it can do its thing
i was thinking the animation class
it doesn't really matter where that code lives, as long as it lives somewhere
private void DoJumping(InputAction.CallbackContext obj)
{
if (IsGrounded())
{
forceDirection += Vector3.up * JumpingForce;
isJumping == true;
}
}
public bool isJumping;
alright
this is in the updated movement
but now im trying think of how to get the animation class to register that the player has jumped
call upon the method in updated?
if (IsGrounded())
{
// code that makes you jump
}
call a method on the animation class in here
wait, hold on
that method should do whatever needs to happen to play the jump animation.
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
oh, cs
got it
one sec
thirdAniJimp = this.GetComponent<ThirdPersonAnimation>().Jumping();```
tossed it with the getcomponent lines for rb and animator component
WHY THE FUCK IS IT THIS HARD TO MAKE SOMETHING LOOK LIKE IT'S JUMPING
HOLY SHIT
... nvm
i think i found a solution
just use triggers
and now none of the animations are running