Explosion after clicking

Marcel 4 years ago updated by Elin 3 years ago 8

Hello, I am a new bolt user and programmer.

I would like to ask how when I clicked on a given part of the touch screen, my boxes were exploding and moving in accordance with gravity.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

I think you need a raycast to get the z position. With Mouse.Position you just get 0 as z position. 

Some else... Your box need of cause a rigidbody and the flow Maschine should be on the game object you want to influence with the explosion force. 

And in practice, how will it look like?

Simple Explosion on the Gameobject with the flow machine.

Here i just apply the fore to the gameobject, that got hit by the raycast.
With a layer mask you can ony effect objects on this layer (in my example i used layer 8) 

With an List, containing all Objects, that would get affected by the force


It's just a group. 

You create them with ctrl + mouse drag. 

Last question, why doesn't it work?


It looks like your list variable is empty. 

Also you have the "body" output from the "for each loop" node not connected. The same with item output. Just look at my example. 


don't know where I should do it :(


First you have to create your variable, containing all objects who should be influenced by the explosion. Because the variable is handled over different objects in my scene i used a SceneVariable.

You can manualy add all the objects who have a rigidbody componant to the list or do something like this:

Here i added the following flow machine to all my rigidbody objects.

When they are in the camera vield of view they add themenself to the list of exploding objects. As soon they are of camera, thy remove themself from the list and the physic simulation has only to be calculated to all obects within the camera vield of view.

If you want to apply the explosion force to every rigidbody object you can do this:

With the OnStart event, you first create a new list and save it as your variable. Then find all rigidbody componants in the scene and get its gameobject. This object you can add then to your list.