tags: physics title: Apply force brief: This example demonstrates how to apply directional force to all dynamic blocks on touch/click and draws debug direction lines. thumbnail: thumbnail.png
This example demonstrates how to apply directional force to all dynamic blocks on touch/click and draws debug direction lines.
Scene consists of a few game objects:
controller
/example/apply_force.script and a label with usage text.block1, block2, block3, block4
walls
Proposed settings regarding physics in the game.project file:
A single controller script handles input for the whole scene.
When you touch/click, it loops over all dynamic blocks, computes a force vector for each one, applies the force, and draws a debug line that visualizes the direction.
init()hash("touch") in on_input()force = (touch - center) * force_factorapply_force to each block@render: draw_line for debug visualization