Is there a way to calculate falling speed based on physics body settings, instead of waiting it to fall and getting velocity?

I would like to find what time it takes for object to fall from defined point and hit the ground. Usually using this formula time = distance / speed, but this time speed is a problem.

  • \$\begingroup\$ Hi! Given that a falling object has probably an acceleration (even in a simulated environment, I guess) and during the travel something could happen, I'm not quite sure SpriteKit actually knows how much it's going to take to fall to the ground. Can you give more context? Or why do you need this data? Welcome to this forum! \$\endgroup\$ – sabi Feb 8 at 22:58
  • \$\begingroup\$ Hi, thanks. Game is 2D. Let's say there is an enemy which drops bombs. Player moves forward with constant speed. I would like to trigger enemy to drop bomb, so that it will hit player exactly when player is right below enemy. Maybe there is better solution, but my first idea was to do calculations based on time of bomb traveling and player approaching. \$\endgroup\$ – elektricni Feb 8 at 23:45
  • \$\begingroup\$ Using your formula you could find the speed as speed = distance / time \$\endgroup\$ – Jay Feb 9 at 5:52
  • \$\begingroup\$ I’d implement this particular mechanic as a triggered trap. When the player is moving forward, in the moment he pass a certain Point, the enemy drops the bomb. Then I’d go empirically to find the best Point. \$\endgroup\$ – sabi Feb 9 at 6:36
  • \$\begingroup\$ Yes, that was my plan. :) Problem is finding that point, because it is based on bomb speed, and I don't know which values SpriteKit uses to calculate gravity. \$\endgroup\$ – elektricni Feb 9 at 10:47

Your Answer

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

Browse other questions tagged or ask your own question.