Put around a position

0 favourites
  • 9 posts
From the Asset Store
Like tourists, Travel around the world as fast as you can!
  • The math you need is:

    Set X to CenterX + cos(angle) * dist

    Set Y to CenterY + sin(angle) * dist

    CenterX/Y defines the center point of the circle, at the give angle, with a radius of 'dist'.

    Math is actually really helpful in game creation, it's worth brushing up!

    Do I understand correctly that this is not in the behavior right now?

  • Sorry to not be of any help, but:

    Your username is "clickfusion", your screenshot is from GDevelop, and you're posting on the Construct forums.

    wat

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Gdevelop expressions look overly verbose. Anyways, I’m not sure the question.

    The math of positioning an object with a distance and angle from another object is the same no matter the program.

    X = centerX + dist*cos(ang)

    Y = centerY + dist*sin(ang)

    Or since you know the object you want to move toward you can skip the trig altogether.

    mag = distance(centerX,centerY,mouse.X,mouse.Y)

    X = centerX + dist* (mouse.x-centerX)/mag

    Y = centerY + dist* (mouse.y-centerY)/mag

    Although you could use the move at angle or move forward actions to do that too in construct.

    Sprite: set position to (centerX,centerY)

    Sprite: set angle toward position (mouse.x,mouse.y)

    Sprite: move forward dist pixels.

    There are likely other ways too. My answers are construct centric.

  • R0J0hound I asked the wrong question. Why is this functionality not in the actions? I think this is a useful mathematical formula that can be added to the actions on the object.

  • I have no answer for that. You can add the request to the ideas platform and maybe they’ll eventually add it or say doing that with current features is good enough.

    There’s probably a balance between a minimal useful list of actions and a list of every useful function.

  • Actually, there is an action for this - Sprite Move At Angle

  • dop2000 No. "Sprite Move At Angle" this is not an analogue of this formula.

    Example. Using the formula, I can make the sprite move in a circle no further than the specified distance (for example, analog joystick). What is very similar to the action "Pin -> Pin at distance"

  • Using the formula, I can make the sprite move in a circle no further than the specified distance

    You can do this with two actions - first set sprite position to the center point, then move at angle.

  • dop2000 Now I understand what you me talking about. You're right.

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