Class KX_NearSensor (2.48)


Methods
getHitObject getProperty
getHitObjectList setProperty
 
Variables
---------- ----------
 
Constants
---------- ----------

Inherited Methods:  Class SCA_ISensor
getFrequency reset
getInvert setFrequency
getLevel setInvert
getUseNegPulseMode setLevel
getUsePosPulseMode setUseNegPulseMode
isPositive setUsePosPulseMode
isTriggered ----------

Inherited Methods:  Class SCA_ILogicBrick
getExecutePriority setExecutePriority
getOwner ----------

Inherited Methods:  Class PyObjectPlus
isA ----------

Inherited Methods:  Class Value
getName ----------



Methods



getHitObject

getHitObject()

Returns the last object hit by the near sensor.

Return type:  KX_GameObject

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the sensor attached to the controller named NearSensor
sen = controller.getSensor("NearSensor")

# get last object hit by near sensor
obj = sen.getHitObject()

# get it's name
name = obj.name

getHitObjectList

getHitObjectList()

Returns a list of the objects hit by the near sensor in the last frame.

Return type:  List [ KX_GameObject ]

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the sensor attached to the controller named NearSensor
sen = controller.getSensor("NearSensor")

# get a list of the objects hit in the last frame
objList = sen.getHitObjectList()

getProperty

getProperty()

Returns the name of the property that the sensor looks for.

Return type:  string

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the sensor attached to the controller named NearSensor
sen = controller.getSensor("NearSensor")

# get name of material sensor looks for
name = sen.getProperty()

setProperty

setProperty(name)

Sets the name of the property that the sensor looks for.

name:
Type:  string

Note:
For setProperty(name) to change the property that triggers the near sensor, a property with the name you're changing to must already be listed under Add Property of the object attached to the near sensor.

If it isn't, the property won't be changed.

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the sensor attached to the controller named NearSensor
sen = controller.getSensor("NearSensor")

# set name of material sensor looks for
sen.setProperty("Wall")



Blender 3D
Game Engine