Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

To physics or not to physics
Started by gforner Jun 04 2019 08:05 AM

2 replies to this topic
physics collision projectile bullet

Best Answer thomas6 , 06 June 2019 - 12:36 AM

I never use physics, and always write my own using simple math.

 

Using math.cos, math.sin, math.atan2 and pythagoras' formula (for calculating distance) is basically all you need. Collission code is often really easy to do, and speed and efficiency are good in Lua, no need for native code unless you're going very high end.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

gforner

[GLOBAL: userInfoPane.html]
gforner
  • Observer

  • 1 posts
  • Corona SDK

I recently started using corona for some pet projects. I've spent a great deal of time exploring tutorials and community code. I'm trying to build a simple shooter as an example and am finding that I keep fighting the physics engine. I would like to be able to move the enemies directly and still be able to detect collisions with other enemies as well as bullets. If I make the enemies static so they don't react to physics then I can move them around, but collisions with other enemies disappears. It's like I need collision detection, and bullet projectiles, but nothing else that the physics engine does... I mean nothing.

So I have a few question although a bit simple some may be somewhat opinion based and most are yes/no.

First of all is there a way to turn off all of the physics bodies reacting and still get collision detection?

If not, would I be better off writing my own collision and projectile code?

If I do, is there a way to write this code not in Lua, but something more native, maybe like plugin code? (looking for speed and efficiency)



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,062 posts
  • Enterprise

This tutorial might be useful:

 

http://docs.coronalabs.com/tutorial/games/nonPhysicalCollision/index.html



[TOPIC: post.html]
#3

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 980 posts
  • Corona SDK

  Best Answer

I never use physics, and always write my own using simple math.

 

Using math.cos, math.sin, math.atan2 and pythagoras' formula (for calculating distance) is basically all you need. Collission code is often really easy to do, and speed and efficiency are good in Lua, no need for native code unless you're going very high end.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: physics, collision, projectile, bullet