Saturday, September 13, 2014

STENCYL - HOMMING MISSILE SYSTEM

Hello! In this tutorial, I'll show you the easiest way to do a homming missile in the creator games STENCYL.

First, we need three actors. Player, bullet and bullet creator. Of course we also need the scene. To simplify things, let's set the tab Collision every actor on sensor mode so that gravity and collisions do not hinder the case.




Of course, we first need to create a scene. When you have found scene. Put on the two actors: player and bulletcreator. It was the easiest piece.


The actor called "player" should have two behaviors: "Cannot Exit Screen" and something that will allow us to move him. I suggest "8 way movement".


The Events tab for "bulletcreator". We need this piece of code that we will create one bullet every two seconds, the starting coordinates are exactly in the middle of the actor "bulletcreator".


In the case of the actor "bullet" we need to make sure that disappears after leaving the scene, or hitting the player. It is therefore proposed to simplify add two behaviors for "bullet".


And now we go to the essence of things and math :)

This is the code that we need to add to our actor "bullet" so as to follow the player.



When we add this code in the "Created" is released missile calculate Current Issues player positions and face in that direction.





However, if you put in the "always" is a bullet will keep update the player's position and will act as homming missile!






No comments:

Post a Comment