This is the AMP version of this page.
If you want to load the real page instead, click this text.

Solved Subway Surfers - Get Player Position

Status
Not open for further replies.

blank667

Platinian
Hi everyone, here's my problem: I'm trying to retrieve the player's position in the Subway Surfers game and I've tried a number of things but I have the feeling that something's wrong.






To begin with, I can retrieve the position of each object spawned on the MAP using the Spawn method of the SubwayEntity class, then working backwards along this path: instance -> get_transform -> get_position.
In fact, you'll notice that the position on the Y axis is always set to 0...

I'm thinking that, quite simply, either the Y axis corresponds to the axis that handles the positioning of the lanes, and this is handled differently, or the Y axis is supposed to correspond to the distance of the objects from the camera or the player.


My problem is that now, when I want to retrieve the player's position using the CharacterMotor instance, then retrieve its Transform and use get_position, THE POSITION NEVER CHANGES...

So, of course, I took a look at the game's code, and I looked at the function that handles lane changes to see how the player's position was retrieved, and I found this:



Ok so we see that the Lane change is done by looking at the current lane and defining the target lane with the lane offset which is an argument to this function.



Okay, but what we're interested in is the player's position, which is retrieved using the get_WorldBodyCenterPosition function.
So I went to this function :)



Ok, so now I know that the position is retrieved by summing the vector3 returned by get_WorldPlacerPosition with the vector3 returned by get_center of the CharacterController class.

So now all I have to do is go to the get_WorldPlacerPosition function :




And here's the problem: that's exactly how I did it in the beginning... and this value doesn't change at all with each frame.
And I don't get the impression that the vector3 returned by get_center doesn't move either...

So after all this analysis (I didn't put it all in), I've come to wonder if it's not the player who's fixed, and rather the objects that advance towards the player or even the whole world.


If anyone has a good knowledge of the game, and has already managed to figure out how to retrieve the player's position, that would help me a lot.

Many thanks to those who took the time to read my entire post.

Have a nice day!

blank667
 
Thread will be set to "solved" and closed.
When you're not happy with that just send me a message and i will re-open the thread for you.

Thanks.
 
Status
Not open for further replies.