How do I rotate a sprite from an image point using physics

0 favourites
  • 14 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi everyone,

    This is my first post on this forum.

    I need help to rotate a paddle from an image point using physics. I succeed with Set Angle, but it glitch because of the physics behaviour.

    I tried to use a limited revolute joint and apply force to the paddle to another image point , but I cannot make it work. I know I'm not really clear but look at these images.

    When player is not pressing "Spacebar",I want the paddle to stay in this position:

    When player press "Spacebar", I want the paddles to smoothly rotate to this position:

    I'm trying to do a game like 100 balls: play.google.com/store/apps/deta ... alls&hl=en

    EDIT: I cannot post a link so i will paste an image of the game here:

    Thanks I hope anyone can help me !

  • Yeah exactly, can you explain a little why you use value like -33333 for the torque force.

    EDIT: I play a little with your capx file and I think that the Keyboard Space event is down does nothing. Because I removed the event completely and the paddle keep going down while Space was not pressed. It look like it's the gravity that make the paddle drop (when not pressing Space), but you put gravity to zero on paddle On start layout. So I'm a little confuse.

    Man if you could explain it, it would be so nice. I already learn a little with you file.

    Thanks a lot !

  • The Keyboard 'Space event is down' ads some counterforce to soften it all some, when you release the things. It might need some adjustment. Else those things jump everywhere if you push the paddles back.

    And yes, 'Space is not down' works against the gravity force. Its just pushing against the falling things. They fall due gravity. Thats was key and a demand in your question. Can rotate those paddles in easyer ways. You wanted it done by physics. And that got me curious. Just like you, i am here to learn by trying to solve other poeples puzzles.

    Regarding the big numbers. Its is a bit like in real live, if you only apply torque, you need a lot of force. Try closing a door by pushing close to the hinges.

    I did't choose those numbers by logic. I just made them big enough to push against the against the gravity, by try and error. To be honest, i did't gave it that much time.

    I just mimicked real life physics.

  • OK thank you for your explanation. Yeah I want to do it with physics. By the way I didn't want to say that you made a mistake. I'm really grateful that you share it. Great work and you say you did it fast !

    But I don't understand how gravity can affect the paddles if the gravity is set to 0.

  • The gravity of the green boxes is not set to zero. In fact, it is set to 10 in the layout startup. Wich is perhaps to much too.

    Each object has its own personal gravity. Each attached behaviour has its own properties. Its is not 1 3D world.

    If you pick out 1 of the green things, and set its gravity to zero, then the others will still fall.

  • Ok I understand that, but what about the paddle ?

  • The paddle gets pushed away by the weight of the green things.

    With its gravity set to zero, it will not fall. It will not feel its own gravity.

    It still feels other objects pushing.... feel forces that other objects apply to it.

    It does not feel the gravity of the green things, it feels the weight of the green things caused by there gravity.

    W = m * g

  • You answer my questions, thank a lot, I think I must find another way because like you said, the paddle are making the square goes through the roof if the paddle come back really fast.

    Thanks for taking the time to help me!

  • Well i am totaly wrong. You made me doubt myself.

    Look at this:

    https://drive.google.com/open?id=0B1SSu ... 1A2d3BSRG8

    If you change the gravity of 1 object, you change the gravity for all objects.

    I apologize for saying dumb things (again).

  • Why does the other green square doesn't get his physics enabled when you drag?

    The drag drop event only affect the "contextual" object the event occurs ?

    You help me understand how physics work in this engine.

  • Because it is also not 'enabled'.

  • Yeah but Sprite2 got his physics enabled when you start dragging.

    So how does the engine separate the two instance of Sprite2?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The 'on drag' picks. It selects the dragged object.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)