Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Is it possible to change the physics of a dynamic object to a static (I know that in the properties of physics there is a parameter Static, Dynamic, ?
Started by Artemako Jan 18 2019 09:11 AM

4 replies to this topic
collision static dynamic physics

Best Answer XeduR @Spyric , 18 January 2019 - 10:03 AM

Your question isn't as clear as you may think.

After a physics object has been created, you can no longer change it. If you want to turn a static object dynamic, then you'd need to delete the physics body and create a new one with a dynamic body to begin with.

The reason why two static objects can't collide is due to computational efficiency based on the assumption that if an object is static, then it shouldn't be moving in the first place, i.e. it shouldn't be able to collide with another static object.

What you could do is create a dynamic body but turn it into a sensor. If your app uses gravity, then set the object's gravity scale to zero. This way the object will be able to detect collisions with other objects, but won't physically collide with them (and will be unaffected by the possible gravity).

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

Artemako

[GLOBAL: userInfoPane.html]
Artemako
  • Observer

  • 4 posts
  • Corona SDK

Hello!
Is it possible to change the physics of a dynamic object to a static (I know that in the properties of physics there is a parameter Static, Dynamic, Kinematic)?
I need this in order to count the collision of two static objects, because 
As noted, some body types will — or will not — collide with other body types. In a collision between two physical objects, at least one of the objects must be dynamic, since this is the only body type which collides with any other type.
Thank you in advance    :)
 


[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,492 posts
  • Corona SDK

1. You can change the body type of a physics object.

 

2. Static objects do not collide with other static objects.  They can't move.



[TOPIC: post.html]
#3

Artemako

[GLOBAL: userInfoPane.html]
Artemako
  • Observer

  • 4 posts
  • Corona SDK

1. You can change the body type of a physics object.

I know that in the properties of physics there is a parameter Static, Dynamic, Kinematic

 

Ok, I ask the question differently, is it possible to make the dynamic object not interact (not jump, not bustle and etc) with a static object? (BUT I NEED THAT THE COLLECTION OF THE VOLUMES COUNT OUT)!



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 582 posts
  • Corona SDK

  Best Answer

Your question isn't as clear as you may think.

After a physics object has been created, you can no longer change it. If you want to turn a static object dynamic, then you'd need to delete the physics body and create a new one with a dynamic body to begin with.

The reason why two static objects can't collide is due to computational efficiency based on the assumption that if an object is static, then it shouldn't be moving in the first place, i.e. it shouldn't be able to collide with another static object.

What you could do is create a dynamic body but turn it into a sensor. If your app uses gravity, then set the object's gravity scale to zero. This way the object will be able to detect collisions with other objects, but won't physically collide with them (and will be unaffected by the possible gravity).



[TOPIC: post.html]
#5

Artemako

[GLOBAL: userInfoPane.html]
Artemako
  • Observer

  • 4 posts
  • Corona SDK

Thank you for reminding me about the sensors. I forgot about them. 

I looked at this topic:

https://forums.coronalabs.com/topic/74087-any-threads-on-how-to-make-a-score-counter-for-every-dodge/?hl=issensor#entry390575

 

I had to add these values to the physics of my hero so that everything would work as it should.

physics.addBody( hero, "dynamic")
hero.gravityScale = 0
hero:setLinearVelocity( 0,0 )
hero.isSensor = true
I just wanted that the object counted the collision itself, but not physically.
Sorry for my English.
THANK!!!  :)



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: collision, static, dynamic, physics