# Get the position of an object point relative to the scene

I am making an endless runner car game and for the terrain I am trying to make hills. My strategy is to create a bunch of platforms and link them together through object points. I have most things figured out but the one thing stopping me is getting the positions right. Right now I am setting the newly created platforms X and Y to the previous platforms Front Link point, using PointX and PointY functions. The problem with this is these functions just get the position of the point relative to the sprite and not the scene. Say I have a 64x64 square with a point called MyPoint at 10,10. If I place the sprite in the scene at 0,0, the coordinates of that point relative to the scene will be 10,10 cuz the scene and the square have the same position. If I move the square to 20,20 then MyPoint’s scene x and y will be 30,30. Essentially what I am asking is how to get the coordinates of an objects point somewhat like a combo of Object.X() and Object.PointX(). Also I need to do this regardless of rotation such as if my square was rotated at an angle of 30 degrees. If you need more info I will provide it. Thanks!

-Interpixle

Add a point to your platform sprite where you want the next platform to be placed (say the object is called PlatformObject, and the point is called NextPoint). Create 2 scene variables (nextX and nextY?) and set them to the position for the first platform object.

When you create the platform object, set it’s position to the values of nextX, nextY. Then set nextX = PlatformObject.PointX(NextPoint) and nextY = PlatformObject.PointX(NextPoint).

Trying that now- thanks

This doesn’t seem to work for me. All I see is my original platform.

Can you provide a screen snip of your events?

I’m confused. Object.X() gets the position of the objects origin in the scene. Object.PointX(SomePoint) gets the position of SomePoint in the scene, and includes the object’s transformations. How can you have a hybrid/combo of these functions?

Oh nevermind i was confused about what PointX() and Y() did! Thanks!

Agg still doesnt work. Here are my events:

My platform code is at the bottom, in the repeat 5 times loop. NextX and NextY are specified at the top. The original platform is already in the scene below the car.

Put that repeat 5 times event as a subevent of another `At the beginning of the scene` event :

Also, a few pointers :

1. Don’t use the `Pause and start new scene` to restart the scene. Only use that if you open another scene from which you’ll return to the current scene. Use `Change scene` instead.
2. Is that event at the top of the screen snip in an event with the `At the beginning of the scene` condition?

here. ill give u the project folder and u can make it work? all i need is infinitely generated hilly terrain with those platforms (preferably some big jump capability?). ill give u a replit.com link. give me a sec…

It does work, just not the way you want it to.

The problem is here :

You have 15 platforms in the scene. You need to specify (using conditions) which one GDevelop should use, otherwise it defaults to the one that was first created (the one highlighted with the white selection tags in the image below)

oh dang! i started this from a template so i must not have deleted those platforms. thanks so much!

just one more thing: i just need to know how to get the PointX and Y of LinkFront of the platform that is created in the ‘code’. As in, when I create a platform using the ‘create object ~ at position ~’ I need to know how to do functions like PointX() and PointY() on that object that was just created in that action. Thanks!

When you create an object (and none of it’s type were referenced in any parent events), then it will be the only one GDevelop picks. Like I had earlier :

Any subevents that hang off the Repeat event will only reference the object that’s just created.