#States
1 messages · Page 1 of 1 (latest)
okay
so u do have error
so those r the erors
script isn't running
yea but those have been there for so long
the first one mainly
well they shouldnt
because they will cause weird behaviros
even if script runs
they are easy fix
bcuz of this
anim = GetComponent<Animator>();
thats why
youre setting it at runtime
but its not on the same Object
oh
so it doesnt find it
if ur setting things in inspector u dont need any of the =
in Start
anim = GetComponent<Animator>();
controller = GetComponent<CharacterController>();
get rid of
and get rid of Rigidbody
both?
which stuff
yes cause now script is running
ok
or properly at least
but it still doesnt change states
which state are u in
wait
im changing
its working
but my animations are showing up
wait
what
when i frist play gae
game
my animations work
but not he sprint
not the
wait bro
whenever i reload
it works
whenever i reload
is an easy ass fix tho
dont woorry about animations rn
get the states working first
once states work, the animations will fall into place
they only worked
so we're on the same page
yea im able to sprint while crouching
cause its never going into crouch state
reload?
wait
cause I accidentally if key is not pressed
and if not animatoing in coroutine
it exists out immediately after
the crouch should be if i hold down, and then let go it should get out ot crouch state
crouchKey => Input.GetKeyDown
u set this to GetKeyDown thats why
yeah h/o let me test sum
ok I think it's fix
a few things
but nothing is changing
ya easy stuff np
I was completely lost before u started to help
jumping into statemachines from the beginning like this isn't gonna be easy
ah it's stil toggling for but state is fixed
lemme see if I can maybe just make 2 coroutines, 1 to stand and 1 to crouchdown
ok
it works
lemme send
what did u change
a few things
you can compare if you want
not much from original
just removed a few functions
crouch was also being called with keyDown in the handlemovemnt
without bool
wait dude
if I press shift while crouching, it just goes back and forth from sprint and crouch
do u know why
get rid of sprint in Crouch
if (sprintKey)
{
Sprint();
}```
forgot that
yup , removed it and it fixes
yea
now i gotta fix animations
its playing sprint animation if i press shift while crouching
it shouldnt
did u remove the sprint from crouch ? no reason it would trigger tat
ik im stupid i realized i dont have an isrunning bool anymore. I made all my movements in a blend tree thats why
so i have to fix that up
oh ok. as long as the logic works
yea
the animation should be easy
ye
i have to fix the blend tree constraint
thank you so much
for fixing my problem
lifesaver
sure thing!
wait i hve one question
ya
go ahead
lol okie
oh wait
if im sprinting, then pressing control to crouch, im still sprinting at that speed
do u know how to fix
yeah forgot to add this Speed = crouchSpeed;
inside of State crouching
shouldbe ```cs
case MovementState.crouching:
{
Speed = crouchSpeed;
if (!crouchKey && !duringCrouchAnimation)
{
if (isCrouching)
{
HandleCrouch();
}
}
}
break;```
you could tehcnically make this the same line anyway
if (!crouchKey && !duringCrouchAnimation && isCrouching)
yea i fixed it
thanks
oh yeah my animation problem before was that i could go into sprinting animation while crouching lol
and for some reason
my blend tree isn't displaying
the velocity
here its supposed to display the velocity
when im playing but it doesnt
well then show that part lol
eh not sure what this supposed to do
it doesn;t even take into account the movement states
the script?
should just be velocity = controller.velocity.magnitude
where
remove all the rest in update
in the animation script
what
huh
this is for my beldn tree
blend tree
Animator anim;
float velocity = 0.0f;
[SerializeField] private CharacterController controller;
int VelocityHash;
void Start()
{
anim = GetComponent<Animator>();
VelocityHash = Animator.StringToHash("Velocity");
}
void Update()
{
velocity = controller.velocity.magnitude;
anim.SetFloat(VelocityHash, velocity);
}```
wait why ?
why not?
you already have the speeds from character moving
just move them over
just try it first
it shouldnt affect any other animation besides the Float param
yea
it affected my moement animations
idk maybe idk what ur transitions are
it shouldnt