Translations

Know another language? Translate this tutorial!

How to get XY coordinate with distance and angle.

Favourite 15 favourites
Tutorial written by XGDragonOriginally published on 6th, March 2013 - 3 revisions

If you have used GameMaker, you might know this as lengthdir_x,y. This isn't available in Construct, but really its just a simple formula. For that reason, this tutorial will contend with being one of the shortest out there.

I recommend making a function with the following ACE:

What this calculates is the relative X or Y coordinates based on only the knowledge of how far and at what angle the point is. Add the returning number to your objects X or Y value to get the proper coordinates of your target.

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Comments

0
DEEPA K SINGH 2,504 rep

great...it was helpfull

Wednesday, March 06, 2013 at 11:57:26 AM
3
Hillstrom 4,593 rep

Nice one, good to see it as a function too.
Maybe you can add examples of usage for this kind of funcions. For example for a custom turret behavior or other IAs.

Wednesday, March 06, 2013 at 1:31:08 PM
0
Discant 1,559 rep

This is exactly what I was looking for the other day when I was trying to rotate objects around arbitrary origin points. Thanks!

Thursday, March 07, 2013 at 4:02:58 AM
0
RandomExile 12.2k rep

Excellent quick explanation! I like Hillstrom's idea of adding practical examples so we can see it at work.

Friday, March 15, 2013 at 6:04:48 AM
0
BillionYrBunker 2,674 rep

Brilliant. I have been attempting to do this on my own for about 2 hours now. Much appreciated.

Friday, March 22, 2013 at 7:51:30 PM
0
Sirosky 1,912 rep

Thanks bro! I was wondering about this... just transferred from Game Maker =D

Wednesday, March 27, 2013 at 8:32:47 PM
0
Aphrodite 17.2k rep

To complete this tutorial, I suggest you to add this function, which does the opposite:
(this is a screenshot of the event sheet)
dl.dropboxusercontent.com/u/10035971/images/Coordonneespolaires.JPG

@XGDragon

Saturday, June 01, 2013 at 11:21:00 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.