[SOLVED] Get X and Y of a point to use it in condition?

I have Player object with 1 additional point called ActionPointDown and it have X at 8 and Y at 24

How can i use either that point name (ActionPointDown) or X and Y of that point in a condition?
All player animations that are facing down have same ActionPointDown in same X and Y

And for all right animations i have ActionPointRight with different X and Y
I found that in condition i can select player > point inside object
But i don’t need to check if it’s colliding with something
I only need to know either what is the current name of that point (ActionPointDown or ActionPointRight)
Or it’s X and Y to the player object

I think you don’t need points if your game is a topdown and then you player will have 4 animations one for each direction so it’e easy to compare which animation to run when a key or controller button is pressed.
So instead of checking the player point just check the player animation.
Other option you can use is just to compare 2 numbers so the first is a value and the second is the point to compare

Thanks but when i attack player swings his hand towards which is better seen from the side


And in that ActionPointRight i wish to spawn/display weapon for the time of the attack
Also i could then use that to determine which direction my character is facing
So when i stop attacking and player goes back to idle animation according to direction he was facing
Because now i have it so it goes back to down idle animation after attack in any direction

So if i can compare two numbers what would i put in first expression?
I guess something like


But i already tested it and it’s not working
Can i somehow just check if player object have point named ActionPointDown on it’s current animation?

But that compare is not logic, the point is fixed you need to compare the point with other object not the object itself.
If the point is at x=24 y=8 it will always be there.
Alternative if you want to create the object every time you press Attack button you can calculate the distance from the player origin and create the object from there, like a bullet or sword animation.

Well as you see im new here and don’t understand some things
So maybe this can i like CHECK IF TRUE point is at x=24 y=8 with any condition?

And your alternate solution would only give me a way to spawn objects and not to determine direction player is facing

Take a look at this template and try to understand the basics GitHub - UlisesFreitas/top-down-shooter-template: A top down shooter template for GDevelop
There is no need of points in the chacter to determinate the direction you don’t need to mix the actions of direction with attack or other actions.
You just plan your State machine like in a drawn even graphic in paper.
When you have a mockup of your actions then it’s easy for you to transmit that to events into GDevelop.

I can’t even find where you have WASD movement in that template and i can’t understand much from what that template since my game uses 4 directions not 2

So let me explain what i exactly need and if you really believe i don’t need that points to determine anything then i will be more than happy if you explain to me exactly what i need to do to achieve what i want step by step
I have 3 animations (idle, walking, action) for every of 4 directions (up, down, left, right)
If i walk right and stop i figured i need to add condition “right key is released” and add action “change animation of player object to idle”
Doing it to A S W allowed me to make my player face correct direction while stoping
Now when i want to add attack animation where attack needs to work also while walking so i have separate attack animation for all 4 directions how would i do that?
And let’s say i use space for attack so how to character face correct direction when space is pressed?How am i supposed to check which direction my character is facing?
In all 3 states Idle, Walking and Action (which will serve as attack also)
I know how to use that kind of information in Action i just don’t know how to get that information and in which condition?

Show me your events of how you move the player.

I’m guessing here the logic here is
A is pressed

  • Set animation = left
    S is pressed
  • Set animation = rignt
    W is pressed
  • Set animation = Up

So to know where to attack when Space is pressed
You just do
If Space pressed And
Animation = left
Create Sword or gun or wherever you want to spawn like
Create sword at player.X(), player.Y()
Set sword.X() = player.X()-sword.Width()
Do sword attack animation
Delete sword

If Space pressed And
Animation = right
Create Sword or gun or wherever you want to spawn like
Create sword at player.X(), player.Y()
Set sword.X() = player.X()+sword.Width()
Do sword attack animation
Delete sword

Since you know the origin point of the player and the width of the sword or gun you calculate that and move se weapon to the position you want when you create that weapon. Plus if you don’t want to create the weapon each time you just add once and set it’s position to player all the time.

I hope you understand the logic if not let me know.

Before you read anything below please answer my initial question
Is there a condition which i can use to check what is X and Y value of current point?
I don’t care do i need it or not for animation i gonna find it useful for other stuff

Here i actually understand everything you wrote
I just don’t know which condition i would use for that
Set sword.X() = player.X()-sword.Width()
Rest is perfectly clear for me
Create sword is create object for sure where delete is delete object

Problem is my player will not always gonna hold a sword not always will have animation left because sometimes it will be animation 1 or 0 or 2 or 3 (i use animation by number not name)

And i know how to spawn weapon then despawn it i learned that from this bomb game example

Here is mine movement

And thx to you i found this
Which after adding all directions for as 1 condition would give me means to perform attack in correct direction
So already thanks but again please answer my initial question is there condition to check X and Y point of a object

This way you can get the point and add the value to a scene or global variable run that all the time then just check the variable

Thx for your help so far i am able to add ever single attack animation and my Player goes back to idle animation in correct direction

But i think you did not understand my question
I don’t need to know what is the X and Y of that point on scene or corresponding to anything

For example in all my down direction animation i made point named ActionPointDown at X=8 Y=24
And that is my question is there a condition to check what is the current X and Y of ActionPointDown
I mean like imagine my sprite of my player when facing left have 15 height in pixels but when facing right it have 16 just because i made that images with different dimensions
And now i don’t need to check how high my Player is on the map or how high my player is corresponding to something
I need to check what is the size of it’s sprite at the moment and for that i know condition exist
I ask if same type of condition exist for checking Point X and Y set on the animation?

That point won’t change relative to the sprite. If it’s been set to (8,24) on the sprite, then it will always be (8, 24) from the sprite’s top left corner.

If its position is different in some animations, then you can use Player.PointX("ActionPointDown") - Player.X() to get its relative position to the sprite’s origin.

I’m hoping this is what you’re after, because once you set a point on a sprite in the editor, it doesn’t change position relative to the sprite.

I was trying to explain that the point is fixed!

I know. Sometimes if something is explained in a slightly different way, then it may all click.

Oh, don’t worry since I no English native is hard for me to explain sometimes.

I am fully aware that this point won’t change and and im exactly after that
Look at this screenshot
For sake of simplicity i could change ActionPointDIRECTION for every animation to just ActionPoint
But for now let’s keep it as it is


For both down animation even so they are different animations i set ActionPointDown to X=8 and Y=24
BUUUUT for Right animation ActionPont is at X=24 Y=8
So if my Player object is standing idle facing down that value actually is different from where he is standing idle to the Right
Again Down X=8 Y=24
As for Right X=24 Y=8

And i believe this is the answer i am looking for Player.PointX("ActionPointDown") - Player.X()

Problem is you assume i know which condition to use it in which is not true :wink:
So with which condition i could use that?
I mean i am really new here and i don’t know how to do many things so can you like show me on a example? screenshot from events would be more than enough

Is this related to your other post about determining if an object is next to another instance of the same object?

Ulisses trust me i was fully aware that this point is fixed read my last reply to MrMen and maybe you will understand what i am after
And i really appreciate your help i am using now method you suggested with check animation of player condition so again BIG THX
And don’t worry about your English i believe my question was confusing enough any1 would have hard time understanding what im after

Nope
If you want to know exactly what i want to achieve i can explain you in full detail but it will be kinda wall of text

Thanks, but I’ll decline - I have a hard enough time reading documents at work without being subjected to it in my hobby :smiley: