Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

lots of missed collisions firing lasers at targets
Started by greg brady Jan 11 2018 12:56 PM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

greg brady

[GLOBAL: userInfoPane.html]
greg brady
  • Contributor

  • 283 posts
  • Corona SDK

Hi,

 

I'm having a hard time with too many collisions being missed (shots are passing through the target) when firing lasers at targets. 

 

I get about 30% contact when lasers are fired at a target.  My physics bodies are big enough, I've slowed down my shots as much as I can.

 

when I spawn a shot, this is my physics body:

 

physics.addBody( torpedo, "dynamic",   { density = 0, friction =0, bounce = 0, radius=16, isBullet = true})

 

and for my player:

 

physics.addBody( player, "dynamic", { density = .3, friction = .1, bounce = .3, radius = 32 } )

 

Any thoughts on what is going on?  This is very important to me finishing my game!

 

Thanks, Greg

Attached Files



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,562 posts
  • Corona SDK

Just for giggles, instead of this:

physics.addBody( torpedo, "dynamic",   { density = 0, friction =0, bounce = 0, radius=16, isBullet = true})

try this:

physics.addBody( torpedo, "dynamic",   { density = 0, friction =0, bounce = 0, radius=16 })

torpedo.isBullet = true

This should be exactly the same, but... I have this weird memory of certain parameters not working as expected unless set after adding the body.

 

Also, my latter code matches the example here:

https://docs.coronalabs.com/api/type/Body/isBullet.html

 

I don't think all physics parameters can be set in the body table (unlike when you use SSK).



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,562 posts
  • Corona SDK

[TOPIC: post.html]
#4

greg brady

[GLOBAL: userInfoPane.html]
greg brady
  • Contributor

  • 283 posts
  • Corona SDK

Thanks Ed, I'll give it a go!



[TOPIC: post.html]
#5

greg brady

[GLOBAL: userInfoPane.html]
greg brady
  • Contributor

  • 283 posts
  • Corona SDK

I set:

 

physics.setPositionIterations(4) -- 3
physics.setVelocityIterations( 10) -- 8
 
That seems to have helped alot, I'll test further.  Thanks for the suggestion, Greg



[topic_controls]
[/topic_controls]