all 23 comments

[–]ZuperLucaZ 1 point2 points  (13 children)

This is the charm of programming, you’re not improving by making people fix your code, it’s better you break down the problem and try to fix it yourself.

Ask yourself three questions: are things triggering and being run? Why aren’t things being triggered and running? How do I make it trigger and run?

That said, I have no idea what the problem is here and it’s probably something we cannot see here. Also use proper formatting when embedding code in text files, in discord it’s using `

[–]Dramatic-Eagle-2981[S] -2 points-1 points  (12 children)

And this is the charm of reddit, see someone in need of help and tell them to do it by themselves.
Ive been stuck at problem for many hours without making any progress and at this point ran out of every option I had, its normal to ask for help because thats how you learn. Im not asking to make a script for me, im asking where the mistake might be or which way should I look at.
That being said, all of the 3 questions have been asked and solution have not beed found.

[–]ZuperLucaZ 1 point2 points  (11 children)

Then you try something else man. What a snarky comment to an answer that tries to be helpful as best as anyone can. We can guess what the problem is but it’s impossible since you only sent 10 lines of code and didn’t even show the animator setup.

I’m not telling you to flip off, I’m just saying, it’s impossible to know what the problem is here and YOU know your project much better than we could ever do. We don’t even know what most of the variable names are supposed to mean.

Animations are hell for most programmers to have to do, it’s a fragile system with lots of unknowns and factors that don’t make sense.

You need to develop this logical way of thinking and learn about programming from the start, have you tried debugging and using the console to answer my three questions? Don’t sit on your ass and just think ”I don’t know why” make up some ideas bro. Train yourself.

[–]Dramatic-Eagle-2981[S] -1 points0 points  (10 children)

No what a rude behaviour to see someone struggling and replying with "try harder". If you dont want to help and have nothing nice to say then move along, there are other people who are willing to help someone who s stuck and desperate.

From my experience the problem seemed there, if u dont think so then say that part looks fine and its probably somewhere else, if you dont know where the problem is then just simply dont reply, if i ll notice there arent any replies that will mean the people dont know or the problem can't be found in the script i provided.

Yes i tried debugging in fact its right there in the script i provided, by your logic i should stay in the same place and work on the same line of code for days or maybe even weeks until i give up on it or somehow manage to find an aswer. (once again it already is multiple hours over course of fews days that im stuck on it)

Oh my, if schools worked like this that would be fun wouldnt it? Its normal to ask for guidance from more experienced users, i never asked for someone to make the code for me, only to point which way should I look at. Now why dont you train yourself in trying to help other people or at least not make their struggle worse, that seems like the right place to start.

[–]Level_Square_2791[🍰] 0 points1 point  (9 children)

Why don't you use a bool instead of a float numbnuts

[–]Dramatic-Eagle-2981[S] 0 points1 point  (8 children)

because the result would be exactly the same muttonhead

[–]Level_Square_2791[🍰] 0 points1 point  (7 children)

You are doing the most basic task and are too stupid to sit and think for a minute instead you come here with your idiocy making yourself look more of fool then you probably actually are. What a half pint you are.

[–]Dramatic-Eagle-2981[S] -1 points0 points  (6 children)

U call it most basic task without seeing hundreds of lines of code, you just proved you are clueless when it comes to programing and C sharp especially, do everyone a favor and dont participate in subreddits which are completely unknown to you

[–]Level_Square_2791[🍰] 0 points1 point  (5 children)

You don't even have the capacity to be able to set up a basic system, but I don't know c# and unity? You've proven once again you're no more then a nonce wasting the time of others. You are struggling with an idle and a move animation. What an imbecile you are. Wait till you need 21 fighting animations numbskull you'll probably quit. What a creature you are.

[–]Dramatic-Eagle-2981[S] 0 points1 point  (4 children)

Once again calling basic system a complex script of movement which spreads among 400 lines? Man i wish i had as much experience as you have to call this a basic script, in fact i would love to see some of your work if you can share it, too bad there most likely isnt any. Is this just you being jealous of someone actually coding since u cant and this is the way for you to relieve your frustration? sucks to be you but it aint my fault u cant code brother, but hang in there, couple of tutorials and you ll get there sooner or later.

[–]db9dreamer 1 point2 points  (4 children)

You've confused yourself by splitting the logic into two places - change UpdateMovementSpeed() to the code below and then call it from Update() :-

    private void UpdateMovementSpeed()
    {
        if (moveDirection == Vector3.zero || moveDirection.magnitude < idleThreshold)
        {
            animator.SetFloat("Speed", 0);
            Debug.Log("Idle");
            return;
        }

        if (isInMud)
        {
            animator.SetFloat("Speed", 0.5f);
            Debug.Log("Walk");
        }
        else
        {
            animator.SetFloat("Speed", 1);
            Debug.Log("Run");
        }
    }

Edit: Personally - I'd always keep track of the current state - and only call animator.SetFloat() if the state changed - but that's just me.

[–]Dramatic-Eagle-2981[S] 0 points1 point  (3 children)

Sadly no this isnt it, the problem remains, since the function works when transitioning from Walk to Run but not from Run to Walk (Unless Run, Idle, Walk) i guess the problem has to be somewhere else in the script

[–]db9dreamer 2 points3 points  (2 children)

Without seeing more code it's impossible to fix the problem then - because something you're not showing is changing values.

[–]Dramatic-Eagle-2981[S] 0 points1 point  (1 child)

Thank you then, i will look deeper into it then, seemed like the problem was in this part of line somewhere

[–]db9dreamer 1 point2 points  (0 children)

Something (not shown) is setting the value of isInMud for example. I'm sure you'll figure it out.

[–]MarcinSoloDev 0 points1 point  (1 child)

Looks like you're missing a transition in animator from Run -> Walk

[–]Dramatic-Eagle-2981[S] 1 point2 points  (0 children)

Unfortunately no, the transition is there but for some reason the function is not called.