Make object overshoot target on purpose

Hello. I have this logic where an Enemy follows a player intermittently. The moment it starts moving, it follows the last recorded position of the Player, stored by the PlayerPosition X/Y variables, it accelerates then decelerates, stops, repeat. All of this works perfectly as long as the Player is far away enough to where the Enemy does not reach the variable stored position. If it does manage to get to the that X/Y position, the Enemy stops and vibrates abruptly before the event repeats again

In these instances, I would like the Enemy to instead of stopping, to continue on the same path until it decelerates to a halt, overshooting the X/Y position. I’m not sure how to do this without messing up the ā€œMove with a forceā€¦ā€ action.

Cause you are checking exact position while you are not adding to exact position

FOR EXAMPLE

We wanna check if variable Score = 100
We start from 0
We add 15 to score when you kill enemy
Good luck

It either will be higher or lower than 100 but never 100
That is why you check if its greater than 100 rather than if its equal to 100

Same here your objects move faster with force than game can register on some frame it being at exact position

Solution
Either check if distance between object and X/Y vars is below something
Or slow its speed when distance is below something

Hi - you’re best off using object timers inside a ā€˜repeat for each’ rather than a wait.
Also i don’t think that the trigger once will work as intended inside the ā€˜for each’. I’m not sure that you need to use for each here …but id have to try it to make sure!
when using a wait …its best to have a trigger once attached to it, but use it outside of a repeat event

Well, I do want it to aim for that exact position if the Player for some reason does not move. And then keep moving past that position if it reached it.

I already have a slow down implemented on the 3rd sub-event. What I’m interpreting from your solutions is to slow down even further and never reach the player? I want the Enemy to overshoot, not undershoot. Overshoot during the acceleration phase or the deceleration phase.

I tried using timers and i couldn’t quite make it work. Either made the Enemy accelerate into the target position or not move at all. But i did change it a bit to remove the Trigger once and added object variables for the player position instead of Scene variables. The ā€œFor each objectā€ is absolutely necessary, by the looks of it. If i remove it the Enemies all go flying to the left for some reason

Can you past either preview link to your game or at least screenshot from it?

Video works better no? You get to see the movement

https://jumpshare.com/s/F9ndTIVLwULfd2MqDDY7

When the Enemy completes 1 movement cycle, by slowing down smoothly to a stop, it means the Player’s position was too far for it to reach. If the Player is closer, then the Enemy will stop abruptly. I want it to keep going into the same direction until that movement cycle ends, overshooting the store Player position

I wanted to see what you have in game to determine what you need
Not to see issue itself cause i know what you are experiencing

Switch to pathfinding instead of forces

so its using an object timer …still using the opacity as a variable …but 1 extra state …253! It does work without a for each object I sent them to slightly different locations so that they don’t all group together. I applied the force only when they’re op 254

have you tried it with pathfinding? …it is kind of ideal for this sort of thing!

pathfinding thing
s with pathfinding and I also added OR with a number expression for distance to target…edit …only setting path when op is 255

Cheers for the help.
I’m gonna check tomorrow but I’m not optimistic. Pathfinding is ridiculously heavy on performance and i’m going to have hundreds of enemies following the player. I don’t think that is a good solution.

Path finding should NOT run each frame
You use action to move object SOMEWHERE
With forces you need that action to run each frame if its instant force
With pathfidning that action is also setting path (checking if object can go there)
Movement is permanent but setting path happens each frame
So that action with path finding should be triggered only ONCE
So path is checked once
And not make calculation for it each frame
WHICH IS HEAVY

I’m aware. I used Pathfinding but now it also behaves janky. The enemies make sharp corners in some instances. Also it solves nothing cause they still stop when they reach their targetX/Y position and I don’t know how to make them move past that point for longer. If i can, then it will be irrelevant whether it’s forces or pathfinding probably

It’s nice but doesn’t achieve what i want. Yes, there will be a chance that some enemies will do exactly as i want and cross the previous Player position and keep going forward, but i want all of them to do it.
Your logic does the left but i want it to do the right. How to achieve that? On the left the distance traveled varies. but i want the distance traveled to be always the same, no matter where the X/Y target position is

You can calculate the position to go to using enemyx+xfromangleanddistance(angle between(enemyx,enemy,player,playery), distancebetween(enemyx, enemyy,player,playery)+extra distance)
And same with the y

Wait wait wait
I think i read your issue wrong

You WANT them to overshoot
And not prevent them from overshooting?

Because if so you add force to enemies toward angle not toward position

Enemy.AnlgeToPosition(X pos,Ypos)

@Domanating OK NVM im stupid
Your title clearly states what you want

So
Did i get it right this time?

That’s works perfectly!.. but how does that work? Why would the Heart moving between it’s starting X/Y position and the Player X/Y position make it slide further than Player X/Y? If I use force AngleToPosition as you suggested on the previous post it still stops abruptly the same way a ā€œmove to position with instant forceā€ action. Why would ā€œAngleBetweenPositionsā€ work if the AngletoPosition doesnt?

Edit: It’s because i don’t have a condition to the force action… isn’t it?

Because you used it in wrong place

Look NOT SO PRECISE BUT

If red is heart and yellow is target position
Then on left scenario angle HEART TO TARGET is around 45
On right angle is around 225
It changed
So if heart get past its target then angle change

BUT if we store left scenario X and and Y position of heart to variables
And then X and Y pos of target to other variables
AND DO NOT CHANGE THEM until speed is 0
Then angle remains the same
Since angle between these positions is SOMETHING
Positions do not change since we are not overwriting variables

BUT with Object.AngleToPosition() USED IN ADD FORCE ACTION
We are constantly overwriting heart position

Same exact logic but with using Heart.AngleToPosition() in variable

To put it simply
Imagine i am asking you how much ammo you have in your magazine AFTER you reload pistol
NEVER you gonna tell me its 0 and actually you will always say its max ammo for example 10
Cause i only ask ONCE when something happens
And i do not ask how much ammo you have after your each shot

Same principal here
We do not update angle/positions constantly but once when nothing is moving

And in my example in previous message i on purpose used angle between positions and 2 variables since that you cannot put in add force toward angle action and you would NOT overwrite any vars each frame

it’ll need to wait for tomorrow cause im having a hard time wrapping my head around this. It makes absolute no sense to me to put the force action on the condition that speed is above 0. I know it’s not the actual speed but the variable Speed so it doesn’t really mean it is actually moving but twists my brain outside out.