Face Target

barichter

  • Posts: 12
So, I just discovered Stencyl a couple of days ago and am having issues. I am just trying to get a group of actors to all face one actor when I move it around the screen. I have downloaded the Follow Target behavior on StencylForge but there are no instructions and I have no idea how to get it to work.

So, I tried using the Actor->Position->Point actor towards [] degrees, but I can't figure out how to get the x and y coordinates of my main actor since my only choices are  Last Created, Last Collided, choose attribute, and Self. I figured there would be a list of actors someplace.

So, as you can see I am pretty new to this and if someone could just point me to the right tutorial or something that would be great.

Thanks

t4u

  • Posts: 418
Have you done tutorials? No? Then do it first for f*ck's sake and spam forum afterwards!

Depending on your approach the solution may vary but:

1. I assume you create main actor and group actors in scene behavior in such way

When created
Create main actor
Set main actor to last created actor
Create member of group #1
Create member of group #2
Create member of group #3

2. In actor behavior for member of group

When created
 set Main actor to [for this scene get [main actor]  from .... scene behavior]
//Main actor is attribute inside actor behavior
//main actor [with small letter] is attribute in scene behavior


Update
Point self towards Main actor
USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/

barichter

  • Posts: 12
Thanks. And yes, I did the two tutorials but didn't see anything along these lines.

ceosol

  • *
  • Posts: 2279
facing targets can involve the arctan2 function. Y is the change in y coordinates from the two target. X is the change in x coordinates from the two targets. Set this value as degrees, abracadabra, you have the angle to face each other :)

stefan

  • *
  • Posts: 2263
for the Follow target behavior, all you need is to add the actor that should be followed in the behaviors panel as far as I know.

barichter

  • Posts: 12
Thank you all for the responses. However, there are two issues.

1. How do I get the location of the main actor? When I add an event to the other actors, my only choices are  Last Created, Last Collided, choose attribute, and Self. Seems like I should be able to get the location value of any actor, but I don't know how to do that.

2. When I try to use the Follow the Target behavior, I apply it to my secondary actors but I cannot see how to tell them to follow the main actor.

Thanks.

barichter

  • Posts: 12
Ok, I discovered how to get the Follow  Target Behavior works, but I am not sure how to replicate it. I had to go to the Scene and click on the actor, then Inspector, then properties/Customize then set the target actor. But how do I build that customization panel? And is there a way to change it programatically during runtime?

PhilIrby

  • Posts: 545
Fear not, you do not have to build the customization  panel.  Its part of Stencyl's tool set and you can always access it to customize any actor that has been placed in the scene before running the game. In order to select your target during runtime you need to obtain a reference to a specific actor on screen.  If that specific actor is  the last created actor or last collided actor, then you can use that reference  like this ;Set Target to Last Created Actor or Set Target to Last Collided Actor.
If your not able to use those references you can use the get actor blocks located in the palette  -Scene->actor->Get Actor. These will loop through all actors or only those of the specified  actor-type or those in the specified collision group and so on.  For example if you have only one actor of type Player and it needs to be your target, you would want to use the For each [actor of type] (Player)  block like  this ;   

for each [actor of type] (Player)
 set TargetActor  to [actor of type]
notice  you actually use the red [actor of type]  as the reference to the player actor