0
$\begingroup$

Say I I’m shining a flashlight (spotlight parented with camera) at something, how do I make that something react a certain way. (Ie. what sensor do I need to use for an object to be able to detect light?)

Any simple tips would help, just a beginner here.

$\endgroup$
2
$\begingroup$

For the light itself you can't, but you can fake it using a physics object with the light shape and detecting this object through collision. The file below is a working example, and contains the instructions below on the Text Editor for convenience.

Use the Outliner to click the described object and check the given properties.

Project Structure

  • Scene '_lib_props':

    • 'player' objects in the first layer, all added to the group 'player'.
    • 'box' objects in the second layer, all added to the group 'box'.
  • Scene 'scenery':

    • 'ground' and 'walls' are mesh objects.
    • The 'player' is a group instance of the group 'player' from the lib scene.
    • The 'boxes' are group instances of the group 'box' from the lib scene.

Player Structure

Check the Outliner for a better overview of the structure of the player.

  • Object 'flashlight_lamp_collision' is a mesh object parented to 'flashlight_lamp', and it contains the following properties:
    • Property 'flashlight' to be detected by the boxes.
    • Physics type Static, Ghost enabled, Invisible enabled, Collision Bounds set to Triangle Mesh.

With these options, this object can be detected by the 'box_sensor' objects.

Box Structure

Check the Outliner for a better overview of the structure of the box.

  • Object 'box_visual' is a mesh object parented to 'box_sensor', and it contains the following properties:

    • Physics type Static, Collision Bounds set to Triangle Mesh.

    • Object 'box_sensor' is a mesh object, and it contains the following properties:

    • Physics type Sensor, Invisible enabled, Collision Bounds set to Triangle Mesh.

With these options, this object can detect the player's 'flashlight_lamp_collision' using a collision sensor.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.