#Platform moving back and forth (Solved)
1 messages · Page 1 of 1 (latest)
Shit I never specified I was working with 3D
I also forgot I wasn’t asking google, I was asking discord, cause i’ve already tried browsing ^^
I'm putting as much effort into answering you as you've put into asking your question.
In it's current form we have no idea what you've already tried. Why the things you've tried don't work, what issue you're currently facing etc. etc.
First, I didn't know CTRL+C, CTRL+V was that much effort, second, I'm trying to use GDScript to make a 3d platform move back and forth, this is what I've written:
The thing is, we want to help you learn how to solve issues yourself, rather than being told how to make something.
If you list what you currently have, why that doesn't work, if there are any errors it makes it a lot easier for people to point you in the right direction.
Just saying what you want to do without any kind of context or saying what problems you're running into or struggling with, makes it a lot harder for anyone to point you in the right direction and would require a person helping to start a guessing game.
The problem I'm having is the platform just moves forever, never comes back
Also if I was wanted to solve this myself with the 4 hours of experience, and a playlist of videos and courses, why do I have access to an entire forum meant for helping me?
Or anyone who needs it
Don't do equality checks with floating point numbers (numbers with decimals). They're not precise enough for this and can cause issues. Check for greater than or equal to (>=) and smaller than or equal to (<=) instead
Because we want you to learn, being told what to do won't teach you anything. Like it or not.
So why's this forum a thing?
Because we can still help you move into the right direction? We expect people asking questions to put in effort into both figuring it out and providing enough information for people to actually help.
We're not here to do your work for you.
Congrats, this entire thing was a miscommunication -_-
I'll just delete this post and never come back here
w
lmao

saucy
just give your issue and ask for help, if the problem is google away then that's faine
Also I just tried that, still drifting farther and farther away, like my father
Judging from the few messages up, I looked at google then came here after finding nothing
you'll have to specify the limits on each axis; the platform position could easily miss an exact vector even with an epsilon
what's the position when you print it?
You're always changing the position by -0.1 on the z axis. The first statement quite frankly shouldn't be there.
What rogan says is correctish however don't compare to a vector3 rather compare specific axis of position. In this case you seem to only really care about the z-axis so only check for that axis, guessing that position is a Vector3 itself position.z
Use an actual if else if flow, now it's just always checking both if statements which is unnecessary since only one can be true at a time.
Last but not least, I'm pretty sure your comparison is incorrect.
If your z axis is greater than -30 even once, it'll always be greater than -30 meaning that it'll always execute that statement.
if position.z <= -30
move one way
elif position.z >= 30
move the other way
as long as your platform is axis-aligned you can get away with only comparing position.z
Now the platform moves, then stops upon reaching -29.9688205718994
That's most likely because at that point the first if is true again, tries to move that way, moves back the same amount the frame after giving the illusion of stopping.
You'll need a way to detect if it's reach the endpoint and flip it's movement direct based on that.
Which could be done with a boolean
if position.z <= -30
boolVar = true
elif position.z >= 30
boolVar = false
if boolVar
move in the positive direction
else
move in the negative direction
This way your move direction is only being decided when one of the key points is hit, otherwise it'll keep moving in the direction it was moving in.
A single = is always assignment
Comparison requires ==
See https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html
If you forget what operators are meant for what purpose
Godot Engine documentation
GDScript is a high-level, object-oriented, imperative, and gradually typed programming language built for Godot. It uses an indentation-based syntax similar to languages like Python. Its goal is to...
Oh so this is like batchscript?
This is like many other programming languages yes.