(solved) How get x and y of player or some kind of angle for "force" action?

Hey there, im trying to do an attack on my enemy.

The attack consists of reaching a certain distance from the player and the enemy “charges” towards the player, like a human cannonball.

But i dont want to “charge” to the player constant position, i want to get some way the x and y position of player when the enemy start the attack.
Or can be some kind of enemy angle, honestly i dont know how this can work, every suggestion are welcome.

The main problem to charge towards the player position is that the enemy on “charge” start to follow the player when is near and dont pass through, it doesnt look like an attack.

Is a topdown view.

Maybe not the best way to do this, but make a variable for both x and y, and whenever the enemy is ready to charge, change those variables to the player’s xy coordinates. (Trigger once) Then have the enemy charge towards that position. That effectively makes it charge to the position where the player was just at, which is what I think you’re trying to do.

1 Like

Its not a bad idea, im gonna try this

1 Like

It works, the enemy charge at last position of player when the enemy attack started.

But is there a way to add distance? because when the last position is near to the enemy, the enemy start to go around the x and y coordinate for 0.5 seconds (the time above of the force action on code)

EDIT: This works perfectly fine to save X and Y of player last position for other attacks like throw a bomb, however i used pathfinder behavior and add to force angle action the object.Pathfinding::MovementAngle() variable and works like i want.

1 Like

I see what you’re saying, yeah. I think you could also rotate the enemy towards that position at instant speed, and then apply force towards the enemy’s angle.