nouse1337 Posted November 23, 2014 Share Posted November 23, 2014 Hi all, I was wondering if anybody could help with my spawning problem? I'd like to spawn enemies at a random location. I'm using a tilemap for my player to walk around. In this tilemap are element with which the player and enemies collide. How could I make sure an enemy isn't spawned on top of the element that collides with the enemy ? Thanks in advance Link to comment Share on other sites More sharing options...
valueerror Posted November 23, 2014 Share Posted November 23, 2014 well you have to (somehow) find out if there is something at the spawn point... using p2 physics you could do something like the following:var hitObjects = game.physics.p2.hitTest({x: xCoord, y: yCoord});this would populate an array "hitObjects" with all p2 bodies under the given coordinatesif this array isn't empty you should try another location.. Link to comment Share on other sites More sharing options...
Recommended Posts