SOLVED: Actor direction locator

wolf2013

  • Posts: 70
Hi Stencylers

I need a locator for an actor which is out off screen to know where to head to because my scene is not only one way running.
For visual understanding what I mean, I have attached drawing of this idea,
any ideas how to achieve this ?

UPDATE:
found example in BATTLEFIELD 1

« Last Edit: September 01, 2016, 03:30:07 am by wolf2013 »

BMJ

  • Posts: 278
Are you saying that you want a marker at the edge of the screen that will point the player in the correct direction to move in order to find the offscreen actor?

If so, you need the following:

 - The X,Y of the offscreen actor
- An imaginary line that connects the player to this actor
- the intersection of that imaginary line and the edge of the screen

I don't know the precise solution, but it seems like raycasting would likely get the job done, and I believe there's an extension for that. Maybe there is a simpler way ... ?


Justin

  • *
  • Posts: 4716
I made a behavior for this about 5 years ago. It was back when the engine was Flash-only, we used AS3 for code instead of Haxe, and we didn't have the Image API back then, so I'll need to take a little time to update it. As is, it might not do exactly what you want, but you can change it as needed.

https://dl.dropboxusercontent.com/u/9458929/SWF/Offscreen%20Indicator.swf
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

colburt187

  • *
  • Posts: 2416
Awesome demo Justin! Id like to take a look at that behaviour when its ready.

Justin

  • *
  • Posts: 4716
Here's the initial version, kept as close to the original as possible. Rotation seems to be pretty wonky though, so I think I'm going to have to refactor a little and use the image api instead of a draw list.

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Justin

  • *
  • Posts: 4716
Here's the behavior modified to use the Image API. Rotation is fine in this one.

You can either add actor types/groups that you want to track to the behavior settings, or you can point to specific actors using the [register actor] block.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

wolf2013

  • Posts: 70
Here's the behavior modified to use the Image API. Rotation is fine in this one.

You can either add actor types/groups that you want to track to the behavior settings, or you can point to specific actors using the [register actor] block.


amazing :) nice job Justin, this is exactly what I need, so cool!

how to find your behavior? What you have attached is a .png file :)

Justin

  • *
  • Posts: 4716
Yeah, that's it. Just drag the file into Stencyl.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

wolf2013

  • Posts: 70
Yeah, that's it. Just drag the file into Stencyl.

Drag .png image into stencyl ? I need the behavior file :)

Justin

  • *
  • Posts: 4716
No, really. That's it.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

wolf2013

  • Posts: 70
No, really. That's it.

sorry Justin, but I really don't get it.

How to drag an image file into stencyl, where ?

Justin

  • *
  • Posts: 4716
Pretty much anywhere, just open your game first.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

wolf2013

  • Posts: 70
Pretty much anywhere, just open your game first.

ops, I did not know that this was possible :)
Thanx Justin ;)

Justin

  • *
  • Posts: 4716
The behavior shouldn't be too hard to figure out, but here's a really simple sample game.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

wolf2013

  • Posts: 70
The behavior shouldn't be too hard to figure out, but here's a really simple sample game.

Works perfect :) thanks

« Last Edit: September 01, 2016, 02:39:08 am by wolf2013 »