PFollow (of PolyPath)

class PFollow

Defined in PFollow.sc.

A motion class that is used to make an Actor stay within a certain distance of another (possibly moving) object, while avoiding polygon obstacles. This is similar to PChase, except that the Actor doesn’t stop moving when it reaches the distance target.

PFollow is generally used as an argument for setMotion:

; Make the dog follow the ego at a distance of 20
(aDog setMotion: PFollow gEgo 20)
class diagram

Properties

Inherited from PolyPath:

Property Description
client  
caller  
x  
y  
dx  
dy  
b-moveCnt  
b-i1  
b-i2  
b-di  
b-xAxis  
b-incr  
completed  
xLast  
yLast  
value  
points  
finalX  
finalY  
obstacles  
name  

Defined in PFollow:

Property Description
who  
distance  
targetX  
targetY  

Methods

init(theClient theWho [theDistance theObstacles])

Initializes the PFollow instance.

Parameters:
  • theClient (heapPtr) – The Actor to which this is attached.
  • theWho (heapPtr) – The target to follow.
  • theDistance (number) – How close the client needs to get from the target.
  • theObstacles (heapPtr) – Optional list of polygon obstacles. If not provided, the room’s obstacles are used.
doit()
moveDone()