#moving object to vector3 point
1 messages · Page 1 of 1 (latest)
ok so when paused, an object sways around, and when unpaused the object stays in the last position of the sway. this is not supposed to happen because of the vector point
@night solar @stone delta
You want your object to return to vector's position when W is pressed up?
but it doesnt?
@stone delta vector is a position that's stored when entering the pause mode, and the idea is to go back to that position when unpausing
it is because you use getkey, which keeps updating vector's position
yea
yee
no i changed it to getkeydown
that's why you should use getkeydown
Does the object have an animator component?
Or anything else that changes its position
{
cam.Sway();
}``` put this before the input ifs
yeah it does
then use if else
i mean, if else on the input ifs
I bet its because of the animator changing your position
is that possible?
What if you just disable the animator?
let me disable animator and see
nope same thing
doesnt move back to the vector point
what does your code look like now?
What if you change Update to LateUpdate?
Thats what animators do, change positions and stuff
yea feels like something else is moving his character
didnt know that, thought it's only for sprite and models
late update didnt work either
Is it supposed to sway when inPaused is true?
yea
And when its false it should stay at vector?
move back to vector yes
Add this
if(!inPaused)
{
transform.position = vector;
}```
So it overrides it every frame
LateUpdate Im pretty sure because it gets called after animations
the object only appears when pressing W, then when i let go of W, its just static. It appears where I pressed W, then stays static there
just like before
Have you logged the inPaused yet and made sure it works like you want
True when holding, false when released
okay
also debug vector
i think i figured the problem out
when debugging inPaused, its true both times
I think its this line
{
inPaused = true;
vector = transform.position
} ```
Because I'm always setting it to true
Even when its false
Im gonna try something
that is irrelevant, the ifcheck is useless though
you only press getkeydown when it is not paused
is there other way you can pause the game?
even without this, its still true both times
https://gdl.space/openitajay.cpp try this
I told you to debug the values like an hour ago but hey lets waste everyones time instead
does isPaused even debug false at first?
let me try
Yep its useless now if he has GetKeyDown
nope
wait
nvm
i did something wrong
force initialize the static false
I bet hes changing it somewhere else
and can you make it private, so that we can be sure nothing else is modifying it?
ok
then in update becomes true even you're not pressing anything?
even when its private its still true both times
no
only true when pressing W
and false in start
But does it go to false when you let go of W
How did you make it private? Other scripts are using that bool, right?
let me share current code
yea
i just removed those
and just made the bool private
Ofc it was printing true if you log it before changing it to false
you sure you getting 0 errors?
now it says false
did the magic debug log?
should be true followed by a false magic debug
yea
thaat works
i might be doing vector debug wrong as well
but im debuggin vector under vector = transform.position;
then
Debug.Log($"transform:{transform.position}");
in the getkeyup
they r both the same
idk whats wrong
probably my debugging
https://gdl.space/ewemuwoxij.cpp test these
no just the object
this.transform?
should I move the sway to late update?
isnt sway in the late update already?
damn, that wont work ofc
no the script with sway
where did you attach this Pause script?
you are moving that gamemanager?
omg @night solar
what should I change?
?
was that the problem?
wait should I move my sway logic to this pause script or something?
this Pause script should be attached to the player you are moving
to the object im moving?
ye...
oh
let me move it then
it works
thanks
i cant believe that was the problem
sorry
the transform key calls the transform of where you attach the script
it's just a shortcut of GetComponent<Transform>
🤦♂️
Well, good that its fixed... hope you learned some troubleshooting at least, george