#"AtRest: false" is what I'd expect to

1 messages · Page 1 of 1 (latest)

honest herald
#

Yeah, but why my character is not moving tho?

empty plume
#

You said that AtRest is becoming true when at positions that don't make sense

#

Is that not the case?

honest herald
#

I said that AtReast switches from False to True but I had console collapse turned on, sorry for that it's my first time using Unity

empty plume
#

ah, gotcha

#

So what problem are you having?

#

Do you get "stuck" in a move and unable to move again?

honest herald
#

My main problem is that when smoothTransition is turned off I can move freely, but whenever I switch it to true my character:
Moves only by .2 instead of 1 forward, then game becomes unresponsive
Rotates only by 10 in either direction, then game becomes unresponsive

Also, it worked previously for me to turn around freely with smoothTransition = false, only change that I did was to change this:

bool AtRest
    {
        get
        {
            if (
                Vector3.Distance(transform.position, targetGridPos) < 0.05f
                && Vector3.Distance(transform.eulerAngles, targetRotation) < 0.05f
            )
            {
                return true;
            }
            return false;
        }
    }

Into this:

bool AtRest
    {
        get
        {
            bool res =
                Vector3.Distance(transform.position, targetGridPos) < 0.05f
                && Vector3.Distance(transform.eulerAngles, targetRotation) < 0.05f;
            Debug.Log("AtRest: " + res); // Changes from false to true in the middle of the transition
            return res;
        }
    }

But reverting these changes dont fix the problem. I will try to rebuild entire project

deft schooner
honest herald
#

I rebuilt the entire project, it didn't help, my best guess is that AtRest is causing problems, as I tried to debug it and log

Debug.Log(
                "Vector3.Distance(transform.eulerAngles, targetRotation): "
                    + Vector3.Distance(transform.eulerAngles, targetRotation)
            );

For some reason I get:

honest herald
empty plume
empty plume
#

oh, nvm, there it is

#

duh

honest herald
#

Yeah but I guess player won't move because AtRest gets false, and player never reaches theirs destination so they can't move anymore

empty plume
#

Do you have a rigidbody on the player object?

honest herald
#

I think I just found the issue...

#

I wrote 2 Player Input scripts that Require player controller and both of these imported PlayerController script

empty plume
#

you didn't "import the script" -- you just have two PlayerController components on the same object

#

But yeah, I imagine they're fighting each other

honest herald
#

When I added RequireComponent it added PlayerController automatically, I don't recall adding it myself but I might be wrong

#

Yeah it adds back in

empty plume
#

That'd have done it

honest herald
#

I suppose I have to handle my TouchInput and Keyboard Input in the same file? Or what would be pattern here

empty plume
#

I would suggest just getting rid of RequireComponent

#

Have both of the input components reference the correct player controller

#
[SerializeField] PlayerController playerController;
#

add the [SerializeField] attribute and you'll see it in the inspector

#

you can then get rid of that GetComponent call