How to rotate a physical body

Hello people

I have a physical body that moves back and forth and I would like to be able to animate it like this:

transition.to(object, {time = time, rotation = newR, iterations = 0, transition = easing.continuousLoop})

But being a physical body with problems both with its movement (object:applyForce( 20, 0, object.x, object.y )) and with contact with other bodies.

How can I get it without transitions with physics?

So you want transitions without physics? Or different transitions with physics? I am just trying to understand the question.

If you want a physics body which moves directly under your control you can either:

  1. Make it static and moved directly, just like any display object
  2. Make it dynamic, welded to a static, sensor object and move the sensor like a display object
  3. Make it dynamic, attach a couple of touch joints to it and move those where you would like it (this gives you position and rotation control)

I should point out that I have, in the past, seen problems with static non-sensor bodies being moved as if they are display objects. You will definitely see problems (such as the object suddenly disappearing with no detectable errors) if you move a dynamic body as if it’s a normal display object.

do it WITH physics:  add a pivot joint use its motor, or make it kinematic and set its angularVelocity

@davebollinger is absolutely correct. You should be working with the physics engine to move physics objects. There are workarounds, but in the end you’ll be causing yourself pain (and lose) if you fight the engine.

If you find that a dynamic physics body is not updating (tracking display object), because you are manually modifying the position and/or rotation , the body is probably asleep.  (Note: transition.* counts as manually modifying in this context.)

Try setting this property on the object after you add the body:  https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Where this may fail:

physics.setDrawMode("hybrid") local myRect = display.newRect( 0, 0, 100, 100 ) physics.addBody( myRect, "dynamic" ) transition.to( myRect, { delay = 5000, time = 1000, rotation = 360 )

This should work:

physics.setDrawMode("hybrid") local myRect = display.newRect( 0, 0, 100, 100 ) physics.addBody( myRect, "dynamic" ) myRect.isSleepingAllowed = false -- Don't allow sleeping transition.to( myRect, { delay = 5000, time = 1000, rotation = 360 )

Thanks guys I apologize if I was wrong.

The body and as a platform that goes and goes but I need to deter situations that oscillate.

The problem then I do not think the body is sleeping but rather that it is not moving with physics. 

Maybe with a joint it would be okay but how? I would like a fluid oscillation effect.

As it would be just as in the example transition

That can’t be.  

  • If the body is dynamic , forces and set velocity functions will move it.
  • If the body is  kinematic , set velocity functions will move it.
  • If the body is  static , it is not meant to move and the physics engine will not expect it to.

You must also remember/realize, transition.* and physics are completely ignorant of each other.  I’m not even 100% sure if the transition.* changes occur (within a frame) before or after the physics calculations for that frame occur.

Regardless, if you’re trying to achieve some sinusoidal or circular body movement using transition.*, while using physics properties to make the object behave like a platform that pushes or lifts your character…  I’m not sure that you can do this in a pleasing manner.

Can you:

a. name some games that have platforms that move like this.

and/or

b. give some example links to videos of other games that have a movement like you’re trying to achieve with this platform?  Please also include the time in the video where this happens.

@community,

Does anyone out there with experience solving platform physics grok what this thread writer is trying to say and can you give concrete suggestions?

This is the maximum I’ve found I hope I can

https://www.dropbox.com/s/fks3ix1z0gxfhl4/20170516_174018.mp4?dl=0

@Jake,

This is not making a lot of sense to me.  

Explain to us what you want to use this for.  

i.e. Don’t describe the problem in terms of the question you’re trying to solve.  Describe it in terms of how it fits into and is used in your game.

That looks more like you want an animated sprite and a basic body that follows its position.  I say that because in your video, the image is a rounded cloud an you can’t make a body that fits that shape exactly anyways.  Also, I’m not seeing how that cloud can be a platform.  The shape looks wrong.

Finally, I meant (names and YouTube links for) released games.  No idea is new so the motion you’re trying to create/mimic must have some corollary in existing games.

I did not find what I wanted for that I recycled an old video found on the net. The deck should barrack to make it difficult for the player to stay up so that he needs to be careful not to fall.

I’m trying to do this with the help of a joke even though certain special effects like transactions can not create them.

I’m sorry I’m not very clear. Keep trying if I can get what I want to let you know for curious

Jake,

If you are moving the physics body manually (not using physics forces and functions) The platform will not support objects in the way you want it to.

i.e. The behavior and physical feedback will be hinky.  

You’re definitely going to want to use some variants of @horacebury’s suggestions.

Note: I’m done for the day so I won’t be answering back further.  I’m not ignoring you, I’ve just gotta get on to other work for now. Time is money and all that.

All right, thank you very much for your precious time

So you want transitions without physics? Or different transitions with physics? I am just trying to understand the question.

If you want a physics body which moves directly under your control you can either:

  1. Make it static and moved directly, just like any display object
  2. Make it dynamic, welded to a static, sensor object and move the sensor like a display object
  3. Make it dynamic, attach a couple of touch joints to it and move those where you would like it (this gives you position and rotation control)

I should point out that I have, in the past, seen problems with static non-sensor bodies being moved as if they are display objects. You will definitely see problems (such as the object suddenly disappearing with no detectable errors) if you move a dynamic body as if it’s a normal display object.

do it WITH physics:  add a pivot joint use its motor, or make it kinematic and set its angularVelocity

@davebollinger is absolutely correct. You should be working with the physics engine to move physics objects. There are workarounds, but in the end you’ll be causing yourself pain (and lose) if you fight the engine.

If you find that a dynamic physics body is not updating (tracking display object), because you are manually modifying the position and/or rotation , the body is probably asleep.  (Note: transition.* counts as manually modifying in this context.)

Try setting this property on the object after you add the body:  https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Where this may fail:

physics.setDrawMode("hybrid") local myRect = display.newRect( 0, 0, 100, 100 ) physics.addBody( myRect, "dynamic" ) transition.to( myRect, { delay = 5000, time = 1000, rotation = 360 )

This should work:

physics.setDrawMode("hybrid") local myRect = display.newRect( 0, 0, 100, 100 ) physics.addBody( myRect, "dynamic" ) myRect.isSleepingAllowed = false -- Don't allow sleeping transition.to( myRect, { delay = 5000, time = 1000, rotation = 360 )

Thanks guys I apologize if I was wrong.

The body and as a platform that goes and goes but I need to deter situations that oscillate.

The problem then I do not think the body is sleeping but rather that it is not moving with physics. 

Maybe with a joint it would be okay but how? I would like a fluid oscillation effect.

As it would be just as in the example transition