Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Zelda style knockback

Rukiri

Villager
Xy$
0.00
Granted MV probably isn't the best tool for a fast paced A-RPG, it should manage to be able to do Seiken Densetsu 3 which basically has a similar knockback.

Code:
[LIST=1]
[*]// vec1 is the player and vec2 is the enemy
[*]    movdir = Mathf.Rad2Deg(Mathf.Atan2(vec1.transform.position.y - vec2.transform.position.y, vec2.transform.position.x - vec1.transform.position.x));
[*]    if (col.gameObject.tag == "Enemy") {
[*]        rb.AddForce(movedir * thrust);  
[*]    }
[/LIST]
Granted this is from Unity but the principles should carry over, This would basically take the X/Y of the Player/Enemy Objects and push them away from each other, however if say a pixel movement script was used the direction of which the enemy object is pushed back would be diagonal if it's not directly straight from the Player. "Watch A Link to the past, should explain this a bit better"

I feel this should be quite easy in MV considering how much more open it is but I'm having more trouble than I should...
 
Top