HELPP - Random Spawning

jpeterson

  • Posts: 17
(My game is an overhead view game where a scene is an entire map and the camera follows the player around) I made a player controlled actor, and some enemies that freely walk around the map, when an enemy kills the player, he is randomly spawned somewhere on the map. Usually works great until he spawns inside of a line of tiles or square of tiles and looks like he can move but as soon as I try to move, the .swf is frozen and must close. Any random tips or solutions would be greatly appreciated ::) ???

« Last Edit: December 07, 2012, 08:52:29 pm by jpeterson »

LontaBeans

  • Posts: 203
what did you use to spawn, a behavior, or events? if its events upload a picture... :)
Skype name: lontabeans (add me)

jpeterson

  • Posts: 17
The Spawn Actor Upon Death behavior, which I think comes with Stencyl. Still trying to figure this out, actor spawns inside tiles 1/3 times and freezes game when it does. I had a wall that was a square and tried filling it in with tiles but he still ended up to spawn in the middle of it..  :-\

tgbtom

  • Posts: 127
This is a common problem when it comes to randomly spawning things and your scene has collisions. I had a similar problem and its actually really easy to fix. Take a look at Stencyl's Tile API. I'm
assuming that the white parts is just background and not tiles correct?
Either way the fix is pretty easy.

Create two number attributes (CharX, CharY) then do the following:

Set CharX: 'X' of the controllable actor.
Set CharY: 'Y' of the controllable actor.

http://www.stencyl.com/help/viewArticle/47 (*NOTE: You will only need to use "getTileAt"*)

Then useing code blocks, you can  check the ID of the tile the actor is on top of, if it does not = null, then kill the actor and respawn (Without taking off lives).

« Last Edit: December 09, 2012, 07:14:59 pm by tgbtom »
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

jpeterson

  • Posts: 17
Thank you guys for very fast responses, will try both of these very soon and will get back

jpeterson

  • Posts: 17
i just made it so the actor avoided spawning on tiles all together, found the coordinates all around the edge and made it so he will randomly spawn along the edge somewhere