Set XY relative to object

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Moving an object relative to itself is something that I used to find really handy when using TGF/MMF. A similar function would be cool in construct, unless there is already one and I haven't found it <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" />

    By moving an object relative to itself I mean, for example, a character always looks at the mouse, pressing A would make it strafe to it's left regardless of what direction it's facing.

  • There is already a way, and it involves some pretty simple math. It's one of the most basic things when creating just about any 2d game. Construct wouldn't be much of a game dev platform without being able to do this.

    Sprite: Set X to sprite.X+2

    Sprite: Set Y to sprite.Y-50

    etc.

    Shouldn't this be in Help/Tech Support?

  • Perhaps I didn't explain myself well enough, you're solution doesn't account for angle, what I want to be able to do was to move the object relative to itself, as in, move the object to ITS left rather than just left on the screen. Anyway come to think of it I could probably just do a cos and sin thing but it'd be easier if it were built in

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Perhaps I didn't explain myself well enough, you're solution doesn't account for angle, what I want to be able to do was to move the object relative to itself, as in, move the object to ITS left rather than just left on the screen.

    Ah, that's a different story. Sorry.

  • New game, insert a box. Give it RTS movement. Turn rotate object and pathfinding off.

    Events:

    Always

    Box: Set angle to (mouseX, mouseY)

    Box: Move to mouse

    Key A is down

    Box: Set angle of motion to Box.Angle-90

    Key D is down

    Box: Set angle of motion to Box.Angle+90

    Key A is not down

    Key D is not down

    Box: Stop

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