Author Topic: Proximity of Ego to another actor  (Read 2295 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim C

Proximity of Ego to another actor
« on: December 13, 2003, 04:42:33 PM »
Hi:

My short game is almost finished! I have a question, though. If I want to be able to give an item to another actor, but only when I'm within a certain distance of him, how do I do it? This other actor can move, so that complicates things a little. I'm sure there's an easy way to do it. Can anyone help?

Thanks!



Offline Cloudee1

Re:Proximity of Ego to another actor
« Reply #1 on: December 13, 2003, 06:21:41 PM »
Here you go Jim try something like this:

(if(Said('give/fish'))
 (if(send gEgo:has(INV_FISH))
  (if(< (send gEgo:distanceTo(hMan)) 30)
  (send gEgo:put(INV_FISH))
  Print("Here ya go buddy!"))
  (else Print("Stand closer to the hungry man!"))
 )
 (else Print("You don't have a fish to give!"))
)

The other actor moving is irrelevant, on line 3 it checks to see the distance to hMan if it is less than 30 you're close enough, otherwise you're told to stand closer
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Jim C

Re:Proximity of Ego to another actor
« Reply #2 on: December 14, 2003, 12:10:36 AM »
Ah, great! Thanks so much! That's exactly what I needed.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.057 seconds with 20 queries.