Set Position vs Move At Angle

This forum is currently in read-only mode.
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • I need to make repositioning stuff per tick. I have used move at angle because it gives me angle option but I am not sure if it is the right way to do this. I need "teleport" style positioning, so I think it is not TimeDelta dependant.

    Example:

    x = x + 50

    or...

    move 50 pixel at angle 0

    Any advice?

  • How exactly are you teleporting? What's the situation? What is the game mechanic/control style?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • x = x + 50 would work, just make sure it is not a continuous event, otherwise it will zoom out of screen within a few frames. Trigger once, key pressed etc. are proper triggers. Move at angle is fine, too. It is basically like this:

    x = x + cos(angle)*distance

    y = y + sin(angle)*distance

  • Thanks for the clarification Mipey. Basically I wanted to know if there was any differences between them.

  • It's just a handy helper function to do the math Mipey posted for you, so in the case of moving 50 pixels right or moving 50 pixels at angle 0, they're identical.

  • *insert sneaky petition to get rotate around point action*

  • Actions which continually do something or perpetuate are generally not as handy as they first seem. Rotating round a point/object can be done very easily as it is.

  • [quote:2nuxkwl2]*insert sneaky petition to get rotate around point

    im doing this without variables to store the relative angle and distance cause i don't feel like it.

    point.x+cos(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

    point.y+sin(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

  • [quote:25rc33bn]*insert sneaky petition to get rotate around point

    im doing this without variables to store the relative angle and distance cause i don't feel like it.

    point.x+cos(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

    point.y+sin(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

    After all these years, my head STILL hurts when I read your posts... O.o

    ~Sol

    P.S. I still love you.

  • Oh comon Sol, it's just sin and cos, they're a game designers two best friends. Get more acquainted with them!

  • Sin and cos are rife through game design even if you don't use them in events(they're peppered through almost all the behaviors and rendering engine). It can only do you good to learn a little of the maths behind game design!

  • im doing this without variables to store the relative angle and distance cause i don't feel like it.

    point.x+cos(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

    point.y+sin(angle(point.x,point.y,object.x,object.y)+(amount you want changed))*(distance(point.x,point.y,object.x,object.y))

    Move at angle is fine, too. It is basically like this:

    x = x + cos(angle)*distance

    y = y + sin(angle)*distance

    Its just that it strikes me as odd having a shortcut for the smaller latter and not the longer former.

    Can live without it though. It's just odd.

  • To rotate around a point, you just draw a circle around that...

    Moon.X = Earth.X + cos(period) * distance

    Moon.Y = Earth.Y + sin(period) * distance

    To control the speed, just control the period yourself; basically it is angle from 0 to 360, the rendering speed depends on by how much you increment the period. So, just increment the period with time delta, don't forget to subtract 360 whenever it gets over 360. It is neater that way.

    period=period+rotationspeed*timedelta

    period > 360 ; period = period - 360

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