Author Topic: Wander within polygons  (Read 241 times)

0 Members and 1 Guest are viewing this topic.

Offline snobes

Wander within polygons
« on: September 15, 2023, 12:12:41 PM »
Hello

I'm tying to get an Actor (a hen) to randomly walk around within a bounded region.

I have a script that does this by using Random and PolyPaths, but I wonder if there is a simpler way to do this. In English, the script picks a new x,y coordinate, sends the Actor to that coordinate using PolyPath, then repeats.


   (method (changeState newState &tmp nextHenX nextHenY)
      (= state newState)
      (= nextHenX (Random 75 75))
      (= nextHenY (Random 140 140))
      (switch state
         (0
            (if (== gKeyholePic CABIN_KEYHOLE_PIC_SLEEP) (self cue:))
         )
         (1
            (ogre init: setCycle: Forward setSpeed: 60)
            (self cue:)
         )
         (2
            (if (not (gEgo has: INV_HEN))
               (hen posn: 87 159 init: ignoreActors: FALSE setSpeed: 3 setCycle: StopWalk -1)
               (self cue:)
            )
         )
         (3
            (hen setMotion: PolyPath nextHenX nextHenY self)
         )
         (4
            (= seconds 1)
         )
         (5
            (self changeState: 3)
         )
      )
   )


I'm aware of the Wander class, but this class ignores polygons (I'm using SCI 1.1). Is there a similar class where I can pass in a polygon and only that Actor is affected by the polygon and thus will wander within the specific polygon? Or is what I've implemented the way to "wander" within a bounded region?

Thanks.




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

Page created in 0.016 seconds with 17 queries.