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.
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
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
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
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
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?
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.