Random sweeping spotlight
Hi,
I am new to GameSalad and I'm working on my first game. I would like to know if what I am trying to achieve is possible, and If so could you give me a few tips to point me in the right direction.
It is a top down prison break game where prisoners have to sneak past a watch tower without being seen. The watch tower will have a spotlight which will randomly "sweep" around 360 degrees, much light a lighthouse. Another way to explain this would be a "field of vision". You must guide the prisoners to an exit without being seen by the spotlight. Prisoners cannot be seen if they are behind objects in the scene.
This image shows a prisoner hiding behind an object from the searchlight.
I am not entirely sure how to achieve the sweeping spotlight effect, I would like it to smoothly sweep around and also move in random directions. Is it easy to have the prisoners hide behind objects? If you check out this "Office Sneak Out" game: http://www.xygames.com/flash/office-sneak-out it is very similar to what I'm trying to do here.
Are there any particular tutorials that would make this easier for me, or If anyone has time can they explain briefly what rules/behaviors could be used.
Thanks so much guys
Comments
To sweep the light, you could use a Rotate behavior. You'd have to figure out the random part but start by just making a "light" actor (that looks like a pie wedge, similar to what you have above) rotate in a circle.
For the detection of the player actor, you would use the vectorToAngle() function to check if the player is at a certain angle from the tower and compare it to the rotation angle (self.Rotation) of the light actor.
The hiding behind objects aspect might be tricky if you want the object to block the light as in your sketch (by the way, sketches are SO helpful for understanding an idea so thank you for posting one). If the player is touching the object but "in front of it" (between the object and the tower), it shouldn't count as a block, so you really can't use a collide rule condition. I'm not sure about that one.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks tatiang,
It really helps to know which functions and rules to focus on. I have tweaked the gameplay so you no longer need to hide behind objects, and I think it has worked out for the best.
You could have the spotlight "fire" invisible actors that are destroyed when leaving the screen and when colliding with obstacles. On a collision with the player they would trigger whatever happens when the player is caught.
These trigger actors would have to be moving very fast though; I am not sure of the upper limit in gamesalad in terms of velocity, but anything over an acceleration of about 15000 should do the trick.
EDIT: I made a demo for this idea.
https://www.dropbox.com/s/1ttgu3sgjz1n2mo/spotLightTest.gameproj.zip?dl=0
The white box (controllable, badly, with arrow keys) is the player and turns yellow when hit by the trigger particles (red). The black boxes are walls/obstacles.
Hey @TRAVOLTRON,
After reading your post, After pondering about it for a few minutes I thought of some things for you that should work if done correctly. I thought of one way to trick the player's eyes into thinking the light wraps around an object. This could get a little tricky and I'll try my best to explain it. You have your image of the light that is going back and fourth. You then have you object image. Have that image in the layer above the light image so as the light image rotates past the object it goes behind it but makes it look as if it's "colliding" with it. Next I would make an image to match the background going at an angle that goes in front of the light but behind the player and object. This will give the effect that there is no light showing directly behind your object. I took your image and added arrows explaining which things I am referring to to make as actors. This would also work for the ground actor and other actors that you want to give the effect that it is above the ground. Hopefully that makes since!
So now to the part about detecting if the player is being hit by the light. You could try and do what @Spalding004 suggested but there could be some issues that would take a lot of working out to fix. What I would do is make a bunch of long, skinny invisible actors that are the length of the "light". Have them all constrained to the light image. Then what I would do is when they collide with an abject to shorten their length so that it is contently in front of the object but once not colliding it goes back to it's normal length. Then have the light detection rules trigger when these invisible actors collide with player.
I know it's a lot to take in and it's kind of hard to explain through text but hopefully this all makes since and you can understand what I'm trying to say, LOL!!! Let me know and hopefully it works out for ya!