Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Constrain actor to circle

Posts: 5Member, PRO

Like the title says, we need to keep an actor constrained so that it maintains a constant distance from another actor but can still move around it on a circular rail while still responding to collisions. We attempted to offset the center off mass to be in the center to no avail, and the magnitude functions don't seem to work as intended for this (it could just be faulty logic on our end).

Going deeper into the details, what we have is a central actor that is constrained to your finger, and another that hangs below it, with another actor of fixed dimensions between the two. The hanging actor needs to maintain a constant distance from the central actor so there is no gap between the connecting and hanging actor, and if it were to be swung around it would create a perfect circle. We can give more specific details if necessary, and complexity isn't a issue as long as the logic that runs it is rock solid.

Ideas?

• Posts: 387Member, PRO

****THIS IS NOT GUARANTEED TO WORK AND WILL NEED SOME TWEAKING:

You'd have to use the distance formula...
http://www.mathwarehouse.com/algebra/distance_formula/index.php

Make an attribute called DISTANCE then use the distance formula where x1= mouse. position.x, and y1 = mouse.position.y.
X2 is self.position.x on the actor that circles it, and y2 is self.position.y.

Do a constant loop saying change DISTANCE to Distance formula with your above attributes in it^.

Actually I would need a lot of time to think and play with it.... but there's a start for you

• Posts: 2,784Member, Sous Chef, PRO

Sounds like you want a pendulum.

• Posts: 5Member, PRO

Yes, exactly like a pendulum!

@NNterprises the distance formula seems promising but like you said would need a lot of tweaking to get it running. It'll be difficult to adapt that to constrain the actor, and it'll probably be just as difficult making it respond to collisions, but its a start.

• Posts: 387Member, PRO