Alright, sorry for my bad explaination. Lets start at the beginning
I have a player, and an item. When this item is used, and the player is touching this item (code for this works), then the item will fling the player based on their positions. the purple dots in the diagram are basically the positions of an item, and a player. Pretend those are the 2D vectors of the item and player, and I need to be able to launch the player away from the item (note that this is NOT the facing angle of the item, as some items may be attacking from behind). This means that based on the position of the item, and the player, the player gets knocked away from the item based on its position.
Example:
A player is at 30 degrees from an item. the item hits the player, and now at 30 degrees the player gets launched AWAY from the item. This would be the knockback that I am going for.
**The way that I want this coded is NOT with an actual angle, because I need to have an x and y force applied on the player. Here is my DASH code (NOT the knockback) which is an example of the TYPE of script I am using.
this.entity.script.p2Body.body.applyForce(this.entity.up.x * 50, this.entity.up.y * 50);
For knockback, I will be using this applyForce()
method since it works very well for the type of knockback I am aiming for.
As for the TYPE of values I am looking for, I am not ENTIRELY sure, but I know I am looking for values similar to those of this.entity.up
because those values are able to launch the player with an apply force by applying different forces to the X and the Y. I need to have TWO values (one for the X, and one for the Y) which both are multiplied by knockback values I have tested in order to launch the player at a given direction.
Lets answer your questions now, ‘between two entities’ basically means the direction in terms of x and y from one of the purple dots to another.
The vectors in the diagram are just examples of where the player and item could be situated, and if that item hits the player then the player will go flying in the direction away from the item, BASED on the ‘between two entities’ explained above.
The problem has been explained above, and please ask me if you need more help, I know helping people on this forum is a challenge, so be sure to ask for more and more details if you still require more. Sorry for not being clear enough.
Thanks,
Chhes 