Opening of a hinge
I have a hinge which is at rest at horizontal position.When a ball will strike the hinge the hinge should open to allow the ball to pass and close again.Any1 knows how to get the angle of rotation of hinge
Best Answer
-
RThurman Posts: 2,881
Here is a demo. This is one way to make a hinge or revolute joint (to use Box2D terms) with GameSalad.
http://www.mediafire.com/download.php?7dlyumrgchlizg8
Answers
Try this -- make a ball actor and a hinge actor. Make the hinge actor long and narrow and place it in the center of your scene. Both the ball and and the hinge should be moveable.
Shoot the ball up toward the right side of the hinge. (Use whatever method you choose.)
In the hinge put the following behaviors
Collide:
-- Bounce when colliding with actor of type ball
Constrain Attribute:
-- Constrain Attribute: self.Position.X To: game.Screen.Size.Width/2
Constrain Attribute:
-- Constrain Attribute: self.Position.Y To: game.Screen.Size.Width/2
Rule:
-- When: Attribute: self.Rotation > 90
----Rotate To Angle:
------Angle: 0
------Relative to: scene
------Speed: 180
------Run to completion (check)
------Stops on destination (check)
The hinge rotate about pivot point.Hinge should open according to position of the ball and go back to rest after contact. Angle A is what i need to determine
Anyway to get the angle or make hinge rotate accordingly
Did you try what I suggested? It will give you the hinge. It will give you the door. The door will open when hit by the ball. The door will close when (self.rotation > 90).
Try it! You will see!
RThurman
For example, you mention that it rotates in a downward direction. (I assume that means it is rotating in a clockwise direction.) You might have some initial rotation set (to make it rotate clockwise) that needs to be removed. Or it might be something else.
I would suggest posting a video, or posting a screenshot of your behaviors, or providing a link to the game for downloading. That way we can see what the issue is.