0

I want to make a game using sensor to moving component how can i achieve that? The effect something like that https://youtu.be/sFZ-IvlVTTw

spydon
  • 9,372
  • 6
  • 33
  • 63
Definev
  • 21
  • 1
  • 2
  • You can use `all_sensor` package or `proximity_sensor` package to detect something in front of your screen then you can do your animation when the value changes. – Chirag Bargoojar May 28 '21 at 04:50

1 Answers1

2

Just like @Chirag Bargoojar says in the comment, you need to have a separate package to get values from the phone sensors/use the camera as a sensor, Forge2D has nothing to do with this since it is only a physics engine. But it should not be very hard to act upon input from the packages that were suggested (all_sensor or proximity_sensor).

Since you have written flame in the ticket too, you'll have to use the bridge package called flame_forge2d to use Forge2D within flame so your dependencies section of your pubspec file should look something like this:

dependencies:
  flame: "1.0.0-rc5"
  flame_forge2d: "0.6.0-rc2"

  proximity_sensor: ^1.0.2
  # or
  all_sensors: ^0.3.1+2

To get bodies falling with the sensors you'll have to update the gravity in Forge2D according to the output of the sensors.

spydon
  • 9,372
  • 6
  • 33
  • 63