#"AtRest: false" is what I'd expect to
1 messages · Page 1 of 1 (latest)
You said that AtRest is becoming true when at positions that don't make sense
Is that not the case?
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
ah, gotcha
So what problem are you having?
Do you get "stuck" in a move and unable to move again?
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
myb something like this you need:
private bool _res;
private bool AtRest
{
get
{
return _res;
}
set
{
_res = Vector3.Distance(transform.position, targetGridPos) < 0.05f
&& Vector3.Distance(transform.eulerAngles, targetRotation) < 0.05f;
Debug.Log("AtRest: " + _res);
}
}
And inside the class use _res istead of AtRest.
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:
I dont set AtRest anywhere
This does not seem relevant
AtRest is not used to control anything and has no side-effects when you get it, so it is not the problem.
oh, nvm, there it is
duh
Yeah but I guess player won't move because AtRest gets false, and player never reaches theirs destination so they can't move anymore
Do you have a rigidbody on the player object?
I think I just found the issue...
I wrote 2 Player Input scripts that Require player controller and both of these imported PlayerController script
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
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
That'd have done it
I suppose I have to handle my TouchInput and Keyboard Input in the same file? Or what would be pattern here
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