Page 1 of 1

Giving Sight and Sound to your actors.

PostPosted: Sat May 06, 2006 5:02 am
by Fuzzy
Create an actor. You might name it 'ant' and use this animation.
Image

Next, create another actor, and use an image somewhat like this:
Image

Move it off the view area, and set it to not be created at start. You might put its parent as the view, so that you dont walk over it, depending on the nature of your game. It will be used to create a field that will detect noise.

In your 'ant' actor, select create actor event, and then action script editor. You could just use the action, but we want to do some stuff with it first.

In the script editor, select function create actor, and fill out the actor field that appears with AudioRange128 or whatever you called the animation. Make the offset 0 and 0 for this one. Make 'ant' the parent. hit add.

In the next line of the script editor, select ChangeTransparency and in its actor field, select the AudioRange128 actor. Please use a better name than I did! Select the highest level of transparency. Hit add.

Now go back and change that line that appeared. make the 1.00000 into 0.995. This makes the actor too faint to see, but not totally gone. if you can still see it, make it closer to 1.0, but dont go too far, or the actor will not affect other actors.

Close the script editor. Close the create actor event.

Now design your player collide events to collide with that circle. As longs as it has enough non-transparency, it will collide with other actors, but the player cannot see it. In its collision event, have it make the ant do whatever actions you want, based on the fact that the ant "heard" the player.

use something like this image for sight.
Image

Follow the same steps as the soundrange actor, but put the offsets as 64 and -64. That should align the triangle with the ants head. The collision events of this actor can cause the ant to act out whatever is needed, based on the assumption that anything touching or in this field is in sight of the ant. you might need to put off assigning the transparency until you get it aligned right.

Feel free to use these graphics, but simple ones might be better, as you dont need the alpha gradient in them(a simple two color png would be smaller).

Please respond with any comments or questions. If there is any confusion in what I have said, I'd like to hear about it, so I can clear it up.

Here is a example of the sight field in use, with the field being Visible.

Image

PostPosted: Sat May 06, 2006 12:46 pm
by Game A Gogo
cool...hmm

PostPosted: Sun May 07, 2006 4:07 am
by Just4Fun
ThreeFingersPete:
Thanks for sharing this with all of us. It is good stuff and like nothing that I've seen posted in the forum before. Complex, yet simple. I like it.

Has anyone else tried these techniques yet? If you have, how are you thinking of applying them in your games?

I think I will fire up GE and try this one out! :D

PostPosted: Sun May 07, 2006 5:03 am
by DilloDude
I think it's a good idea, but with the hearing, normally you wouldn't necesarily make a noise just when you go into hearing range, so you could try on an event that would make noise, check the distance, or just not use hearing at all. The thing with sight is pretty good, but it's not the only way to do it: if you look at my WWW demo, you notice things like balloons and AAGuns and things, they use a function to find if their face direction is approximately equal to the direction between them and you. But good ideas, anyway.[/url]

PostPosted: Sun May 07, 2006 5:57 am
by Fuzzy
Yeah, you can use the direction facing routines too; depending on circumstance and design, that would be the way to go. How about outlining that technique for the GE users?

This method jives with my current kick of dodging decision making. I suspect that GE does the collision detection regardless; unless you specifically turn it off, so its more like hitching a ride, as GEs collision detection would involve IF, but of a hard wired type.

This doesnt pre-suppose sensing anything, it just outlines a timeslice/distance opportunity to make a decision. Its a field limit to sensory data. It is a type of bounding box, which i am making a post on next.

Lately, i've been interested in showing how to abstract real life concepts into programming. Having your counterpoint presented is a good thing. It allows GE uses to see a variety of solutions to problems.

PostPosted: Sun May 07, 2006 8:28 pm
by Just4Fun
Yes DilloDude:

Would you share your process with us for doing this. I really enjoy seeing different approaches to doing similar things. Sometimes it helps me suddenly understand a completely different concept! :D TIA