Set XY relative to object

New releases and general discussions.

Post » Tue Nov 27, 2007 6:03 am

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 :)

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.
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Tue Nov 27, 2007 6:39 am

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?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Nov 27, 2007 7:26 am

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
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Tue Nov 27, 2007 7:33 am

[quote="Arcticus":3l4xrz12]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.[/quote:3l4xrz12]

Ah, that's a different story. Sorry.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Nov 27, 2007 5:11 pm

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
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests