Lock sprite angle and position

Hello, it’s me again. I have this sprite melee attack animation that has these events going as per the image:
-Rotates around the player (topdown) at set distance;
-Follows the cursor;
-Always facing outward towards enemies.

Now i want so that when the attack animation occurs, the attack Sprite:

  • Continues following the Player X and Y;
  • Stops following the cursor, keeping the angle when the animation began;
  • Always facing outward towards enemies.
    I tried subtracting the expressions but that landed nowhere. How do I do this?

Move that 2nd event to the left
From top event move rotate and change angle to sub event
In sub event remove duplicate change angle
In sub event in condition change bite animation is EQUAL TO to NOT EQUAL TO

Move the 2nd event to the LEFT? I assume you meant to the right as a subevent as you further pointed out but it is not correct.

The results from the configuration in the image are as follows:
-Sprite location is correct in relation to the mouse angle;
-Sprite orientation is incorrect, keeps the default orientation that is in the editor (facing right);
-Sprite is detached from the player sprite X and Y.

Yeah right not left

Looking at your screenshot
1st event needs to run ALWAYS there cannot be any condition

Where that sub event should be moved back to the LEFT yes LEFT not right
to become regular event

BTW 2 things

1 - i am clicking REPLY button under your post to make a reply
This way you get notiffication
You should do the same always when you reply
Cause i did not get any notification here that you wrote ANYTHING in this post cause you just made new message here which does not give notification to any1

2 - i am still not sure what you want
Do not explain it again we will get there sooner or later

I am just not sure what you want to happen is what i get out of your words
That is why my suggestion now is different from my previous suggestion

1- Thanks for the info. I didn’t know.

2- I went against you and explained again with a drawing. The results of your 2nd solution are included in the drawing, still not it.

This is to prevent thinking that if you quickly swipe the animation around during those 0.5 seconds you could hit more enemies when you cannot. It also looks cleaner and feels better if the animation doesnt follow your mouse

P.S: For the sake of my intelligence and to not insult the time you spent explaining it, I will read and reply to your post on the “Trigger once per object” thread tomorrow when my brain is more fresh

Edit: When i say that it should “point at cursor but no longer follow it” I mean the sprite keeps the angle from the position the cursor was when the animation started

Yesterday i found you did post something here just by accident
I was bored i was looking on new topics in how do i section
Pure coincidence i saw blue ball next to your topic indicating there is new message
Yeah there is indication of something new in topics
BUT not a notification for users that was active in it
What if was not bored and i would not browse trough how do i section?
I would most likely never knew you did post something new there

So replying to person is not to not insult such person
But to let that person know some communication happen

I did told you not to explain it again not because FU but because i am more than sure you are not aware what you want exactly

I mean you do have idea of something to happen when some conditions are met
But you do not have idea when to block some things from happening

And that part you did not explain well
So instead of you trying to explain it and me trying to understand it
Trust me better way is just me tell you what to do and you say this this is good but that and that does not work
And we gonna build it step by step and get there with time

Look at your screenshot

You have only 3 actions here going from top to bottom they are
1 - Change position of your object or like stick it to player with some offset

2 and 3 - Are pretty much the same set angle of object or rotate it toward cursor

Issue now is
in 1st action you set it to expression player angle to cursor
And you have no means of controlling that cause this action is doing 2 things
1 - put object in some distance
2 - and some angle from player

You would need to make variable call it for example AngleFromPlayer

And put in that action AngleFromPlayer instead of player angle to cursor

In some other event set AngleFromPlayer to Player angle to cursor

Then you can make another var called AngleOfBite
And you set it to again to player angle to cursor
And then in rotate bite action you put AngleOfBite instead of player angle to cursor

So now you have 2 vars AngleFromPlayer and AngleOfBite

For them you set up your events logic to manipulate when they should work and when not

Cause 1st action that put object around another object
Ask for 2 values distance and angle
So if you block this action in any way you gonna block both actions
And you want just to block 2nd value the angle value

And now lets see how much you understand
If you did not catch it and i did it on purpose
You only need ONE variable AngleFromPlayer
In put object around another

And only that needs to be blocked with some conditions sometimes
That action to rotate bite itself does not require variable
Because it have SINGLE value to check
So you can block that whole action itself

So now it would be like

Put object around another with distance and variable AngleFromPlayer
And this needs to run each frame so NO condition there

And 2 more events
1st Change variable AngleFromPlayer set to Player.AngleToPositon cursor x cursor y
2nd rotate bite or change angle of bite set to Player.AngleToPositon cursor x cursor y
It does not matter will you go with rotate or change angle
You just need to pick one but not have two

And now you block that variable and rotate/angle actions by some conditions to not work when you want them NOT to work
And that is all

So when you want bite to still stay in same position from player
same angle but STOP rotating around player while still rotating toward mouse
When it is in attack animation

Then for event which change variable
You add condition animation is not equal to attack
Go do it and tell me does it need more adjustments

Alright, well… How do I block a variable? I feel that’s the core part missing. Is there an action that tells the variable to stop working other than having to change the value of the variable or substitute it for another variable? If the value of the variable is the angle to cursor in relation to the Player, whatever value i choose to stop it must be that specific angle frozen in time for the duration of the attack animation.

I did catch that the extra variable is useless since both actions use the same value (after already writing and readying the 2nd variable)

Note: the 2nd and 3rd actions are not the same but one is in fact redundant and you helped find that out and rid of it. The “Rotate” action allows the sprite to flip if the mouse is between the player and itself (which i don’t want), the “change the angle” doesn’t allow the sprite to flip. Credits to Mr.Men for giving me the good action, i didn’t know i didnt need the other, though. So that means the Rotate action is now discarded

I gonna answer in reverse order

  • Rotate action and change angle action are same thing in your case

BUT
Rotate action is like spin something with some speed to some object/position/angle

Angle action is like take some value and either
SET TO
ADD
SUBTRACT
MULTIPLY
DIVIDE

So rotate is to spin something in this case
And angle is there to make calculations
But in your case it is the same thing

  • Put object around object have 2 values


Distance and angle
You do not want to affect distance but only Angle

So you cannot block whole action
You need a way to affect only one of these values
That is why you put there variable so you affect variable and not that action itself
Rotate/Angle action do not need variable
Cause either you gonna go with rotate or angle you have there only ONE value
So by affecting whole action
You are not affecting anything else

  • BLOCK MY ASS

MAAAAYYYYYYBE
But really just MAAAAAAAYYYYBEEE
It was poor wording on my side

Wait did i just block this action with this condition?
Like i blocked it functionality if LMB is not pressed?
So it only runs/works when LMB is pressed?

In gdevelop condition needs to return TRUE for whatever it is checking
For action to be executed
So whatever you put in condition and it is not true
It blocks action from being executed
TimerFromStart() > 5
This blocks your action until time from start is greater than 5 sec
So your action won’t activate until at least 5 sec passed since scene started

EDIT not 1st but hopefully last
Do you think that let’s say you have action to set angle of your object to angle between player and cursor
Then if that action will stop working cause whatever reason
ANYTHING in engine will magically reset angle of your object to 0 or some other value?
Or will it stay or as you said FREEZE it in its current angle because it was last value it had?

That was rhetorical question BTW

Cheers for the clarification. Though i wasn’t even considering the distance value. I was more thinking the “rotate” “change angle” required the 2nd variable but anyway.

I tested incrementally and immediately with this configuration: just the variable existing and change “put object around” to the variable, there is a problem.

Now the attack sprite is stuck to the right of the player and rotates within itself rather than rotating around the player. It doesn’t even point at the mouse correctly, it’s offset by a few degrees.
It follows the player at least but it stays to the right

Edit: just for testing, I’ve added the variable to the “Change angle” action too and the results are the sprite doesn’t rotate anymore, keeps default position towards the right, still stuck on the player

Why you do not replicate what you seen in my screenshots?
I am not using MouseX Y but Cursor
While they are them same point is why you are adjusting something you do not understand how to adjust?

At the same time why you specify layer and camera?
I just go with CursorX() and not CursorX(“Layer”,0)

Then i spotted this
Its AngleFromPlayer and NOT Variable(AngleFromPlayer)

Tbf there’s no screenshot that i can see showing a “Cursor” expression. There is in your writing but I thought Mouse and Cursor were synonyms.

Yes cause I also have a sprite map in the background layer set to change offset X and Y in relation to player to make it look like it’s an infinite playground. The player and camera are also set up at the layer “Layer”. I’m trying to accomplish what you asked but im adjusting to the scene i have built. If didn’t set to “Layer” the attack sprite would go wack.

I changed the thing to Cursor though it didnt make any difference. Plus if I just type “AngleFromPlayer” it tells me it must be a number. It’s considering it as a string. The variable is correctly setup to be a number btw, default value 0

Edit: It’s an object variable though. Does it need to be a scene variable? Global variable? I feel object variable looks right for the purpose, right?

FAK ME
I was sure i sent you screenshot with CursorX() CursorY()
But no i was using yours

Anyway now you know

About your “Layer” layer
I was sure it have different camera and so its offsets itself cause of that and that is where your problem comes from
Here is another my bad wording
What i mean by different camera is
Different camera settings
Like if you have action to center camera on player on Base Layer
But not on Layer then they have different camera settings

If not then we need to look elsewhere

Fak another mistake
it is object variable
Bite.AngleFromPlayer

Ow you figured its object var
But still you need to reference it with Bite.AngleFromPlayer

This aint making no god damn sense.
Without the conditions it does work like my original events from the beginning of the thread (rotates around player, points at cursor)… but with the conditions… unless you see something I’m not seeing, I’m looping back to the same issue. Fair at least I got the distance saved but I don’t know how to block the variable, or the angle for that matter. These circled expressions must become another value, which is the last angle of the frame before animation start"Player.AngleToPosition(CursorX(“Layer”, 0), CursorY(“Layer”, 0))" but frozen in time during the animation.

If the variable gets disabled, the sprite defaults back to the original position, “around the Player” still in effect but rotation disabled stuck to the right of the Player spinning within itself following the cursor. It has no way of remembering where it was. If the “change angle” is disabled too then it no longer aims at the cursor

Coming back to your rhetorical, question, yes it does reset to “0” and doesnt freeze

Maybe not today but one day you will kiss fate in its fat ass for this

You see right now you are doing what you are told without thinking what you are doing
And because of that you make most valuable things you gonna learn from
Stupid mistakes
I do not learn from them anymore i just make them
You just learned in very unpleasant way what NOT to do
And i always repeat it is not as much important to know what to do than know what NOT to do

Remember how i was explaining to you meaning of BLOCK the action?

Repeat after me
1st events condition
Animation of Bite is NOT EQUAL to Attack
Meaning run action that is right from thins condition
But only when animation of object Bite is anything but Attack
So if its Attack ignore this event
But if its not run it

2nd event condition
Animation of Bite is equal to Attack
Meaning run action to the right from it only when Bite object is Attack animation
So if its something else than Attack not even try to read what is in action section there do not run anything just ignore this event

Tell me will you ever again have problem with knowing if your condition is blocking functionality of your action?

Tell me that mistake was it not worth that knowledge?
Like i told you i was stuck one week on touch joystick
I wrote Joy.X() Joy.X() instead of Joy.X() Joy.Y()
You think i ever did that kind of mistake again?
Well i do i am over 2 years and it happened to me ONLY ONCE since then
Appreciate value of this lesson
I would poop in my pants from happiness something so simple can give me such knowledge

Looking at your screeshot remove crap i cover on red

Yeah, what you’re asking to remove are the extras i added to experiment with. I was a bit too frustrated at the time so i didn’t explain it correctly.
If i do exactly as you placed in the last screenshot, without the 2 lines you stroke in red, the sprite defaults to the right of the Player, so basically it is interpreting as “put around player with an angle of 0 degrees and 150 distance”.

When the animation is not occuring, it probably is following the cursor, i dont know… cause… well the animation isnt occurring. When the animation does trigger then it snaps to default 0 degree position.

The 2 extra lines i added were my attempt to circumvent this issue, which is when it dawned on me i looped back to the beginning: i don’t know how to give it the expression to lock its position and angle

I have only one frame of animation for Attack animation so i shove in there 1 sec timer
To hold that animation for 1 sec then switch back to idle animation

And THIS is exactly what i understood from what you explained you want

  • Bite (knife in my case) rotate toward cursor
  • When Attack animation kicks in it stops orbiting around player
    While keeping same distance in which it was and angle
    But now it rotate itself toward cursor
  • While if its Attack animation you can move player (WASD)
    And Bit will stay in same position it was (to player) when it entered Attack animation

LMB to attack

I will check that once i get home but you understood some things incorrectly. Look at the drawing i made up the thread.

“But now it rotate itself toward cursor”

  • No, in square 3 of the drawing, it must be pointing at the cursor but it must not follow it during the animation. 2 rotations must be blocked: around player and toward cursor.

“And Bit will stay in same position it was (to player) when it entered Attack animation”

-Bite or knife will stay in same ANGLE as player and same direction to cursor when animation starts BUT Bite or knife will still be attached/following the player if player decides to move during animation. (Green text of drawing)
If animation lasted 5 seconds and player moved during that time, the bite/knife should NOT be freefloating when animation began.

If it matters, my attack sprite has no idle animation. It only has attack animation or nonexistent, with no loop to animation and it auto attacks, based on the TimeFromStart you explained

1st of all you need at least two animations if you gonna change animation
Like if you want to change player and you have only one player then there is nothing to change

2nd your drawing is ultra confusing to me i understand from it that nothing

OK we gonna waste time here
So let’s be lucrative

We gonna do it this way
You explain to me only ONE thing i will tell you how to get it to work
And then after it will work for you you will explain to me next thing

So i do not care for
In this state this should be allowed
But also this should happen but that should not

NO

I expect
In this state this needs to happen and this not

I deduce how to do it show it to you and you recreate it and then you tell me ok now i need this

ONE THING AT A TIME

I am very confused how you describe things not cause you do it in a wrong way
But because i feel you are trying to get something else to work than what i understand and that is my fault here
That is why i say going one step at a time will help speed up the process

1 Like

I got it working. The Idle animation you put in your example is what set my gears going. My original sprite had only the attack animation without loop and in order to loop it I had an action to reset it to frame 0 every 2 seconds (TimeFromStart) and that is why, I THINK, the sprite would default back into position everytime it restarted with your method, I assume because it reset positions and could never work with your event propositions. Once the Idle animation was created (In my case it’s just 1 blank frame) then everything worked.
In order for me to get exactly what I requested, I changed the value of “change angle” to the same variable as well and now it does everything correctly. When animation starts, rotate around player and rotate toward cursor are disabled but still following the player X and Y movements.

Here’s the events working correctly following your example with tweaks to fit my idea (The way the animation shifts back to idle will probably change, it’s just proof of concept):

Now here’s the thing, before i did the above I thought, since I had just an attack animation (a sprite that materializes into existence and then disappears), why not instead of having it ever present I would create it and delete it? So I created this:

Which works almost flawlessly. The only problem is it does not follow the player if player moves X and Y, I assume because it only activates on the 1st frame. So IF there is a an easy way to to accomplish the X and Y movement together with the Player without adding more clutter of events relative to the working method please do tell me, cause I do like a method that uses less stuff to accomplish it. Not a problem otherwise, you had a lot of patience already. Thank you, m8

Just wanna you to be aware
Reason why i told you we need to go step by step
Is because i prepared events for you EXACTLY as you described what you expect to happen
And because you said it is not working as you want
I was assuming you meant something else from what i understood
Where issue was lack of idle animation

For your take on the logic with creating object when needed and then deleting it

These two actions cannot be here
They need to be in separate event
Most likely without any condition but now you know how to adjust that if needed

A