"Glide To" and Vector Addition


I'm working on a project where I occasionally want some object to have another source of movement incorporated into current movement. From what I can tell, Glide To will override an existing glide to instead of incorporating both.

To specify what I'm wanting to accomplish, I'm going to make some assumptions for the sake of explanation. I'm assuming that when "Glide To" is used, a vector is created, going from the origin of the sprite it was called on to the desired location. What I would want is to create some other Glide To that would add to this vector. For example:

Say we have Sprite A at location (0, 0). I call Glide To (100, 0 over n seconds), then I call Glide To (0, 100 over n seconds), I would want the sprite to move to (100, 100) in 1 second. My problem does not need to account for varying n values, as they are always 1/30s.

My current idea for a solution is quite messy, and that is to keep a MovementVector variable for each sprite, which other sprites will modify, then one singular 'glide to' is called at the end of its logic loop. This brings in a lot of overhead to worry about and a significant amount of refactoring, so I'm wondering if anybody on here can help me think of a better solution?


You may try this minimal custom block
untitled script pic - 2022-11-17T205057.383
BTW: 60 steps take 1s.

When vectors are used in this manner, they provide relative movement via absolute positioning.
untitled script pic - 2022-11-17T205423.201

But if you want to create more sophisticated approach a kind of "MovementVector" is a good idea.
To implement Newtonian Laws each sprite should have local variables like mass, velocity, force and constantly updated position
untitled script pic - 2022-11-17T212021.021

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.