Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Line of Sight, Raycasting, Wake on Distance
  • Hi,

    Is there a way (components, expressions, etc.) in GBS to achieve line of sight, raycasting, or wake on distance for game objects that need to react to the player? Not necessarily follow the player, but activate their physics or animations when the player reaches the correct distance from the object. So start Asleep, but Wake on Distance? It's the same principal as using a collider trigger to open a door when the player gets close enough to collide with it, but using distance from the door instead.

    If you have only a few doors in a scene or level, using a collider based approach is fine. But when there are potentially hundreds of objects or more, using distance would seem much more manageable. Is there a way to do this in GBS?

    Thanks.
  • 3 Comments sorted by
  • Hi @Anim8, I would recommend using a large collision shape on your object and just making it a sensor to detect when an object has entered within a certain region or proximity to the main collider and then respond to that collision event to activate the object. You can now listen to collisions on an object and check which shape is involved in the collision by name. So you could have a "hitArea" shape on your object which is a Sensor (so it doesn't physically interact with the scene) and another shape that is a collider with a different name on the same Spatial. This is probably the less expensive approach.

    The alternate approach would be to have your player object constantly search for a specific object (maybe while it is moving) like a door or some other object type within a certain range using the Find In Range action. Perform the search with the "closest object" mode and GBs will find the closest object in proximity to your player within a certain distance. The only thing you can't do currently (through the editor) is detect if an object is obstructing the players view to the obstacle. You will need the Line of Sight action for this which is not available yet. It will be added in the build of the next version v1.0. By using the first method above you can avoid needing this.

    There are tutorial videos on both of these techniques on our http://youtube.com/gamebuilderstudio channel.
  • I've tested 27 game engines to date, that I can remember. Only a few of them had a visual programming workflow (or a worthy one), and even fewer included a working 2D Platform Player controller out of the box. You have both. I am very impressed with your software! Very intuitive and user friendly.

    I was able to use the Find In Range action and the targtSearching/targtFound properties to get the object to appear to activate its physics (falling from a location above the player) when the player comes within the set range, but it really just moved downward at the speed set by the Find in Range trigger "Move".

    image
    Simply having the object start asleep, and then using distance from the player to awaken it and activate it physics is the ideal workflow, but the above is a decent workaround. I'm just not sure whether the second Trigger Action in the Rule to Change Property to "
    targtFound" is working or not. Is there a way to test if "targtSearching" has ended?

    I'm only a few hours into testing your engine, so as I attempt to build out my game prototype, I imagine I will have more questions. Is this the best place to ask them?

    Thanks.
  • @Anim8 the Find In Range action is continuos, it doesn't end unless it is not being triggered. So you need to set a Boolean property to indicate when you have found an object. Then move toward that object when the value has been set to true. You can also store the information of the found object from the CurrentActionData property. You don't want Find In Range action to constantly be running if it is not needed.

    Yes this is the best place to ask questions or you can submit a support ticket from the main site by clicking contact us. 

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion