Keule' first wave of questions

Hey guys,

just started with Gdevelop and I have few questions (I went trough the 2 tutorials and slowly start reading trough the forums).

I created an enemy that’s patroling. Then I made a object in the path of my player, that changes the enemies behaviour to stop, go to a shoot animation.
How can I make him face the player, as soon as I trigger the object? I just used a horizontal flip to flip his graphic, but I think there is a beeter way, and I think it causes me problems with the bullets. Because they are shooting in the wrong direction. I also think I could have done the whole thing easier, without the deleting of the GoRight and GoLeft.
Also, is there no behaviour for enemies? I would like to have my enemie walking on slopes.

Also: I tried to make a Stamina Bar. I wanted 4 different sprites displayed depending on the status of the “bar”.
I wanted my character to stop when pressing “k”, change it’s animation and fill the stamina bar.
But when I use the condition “k is pressed” and the action change the animation, the character only plays one of the 2 animations, even though I want him to play the animation and hold the second one until I release the button.
Is it because I have another Event that checks if the player is standing still on the floor and they try to work at the same time?

Thanks guys. Amazing programm but unfortunately not too many tutorials yet (or I still have to find them).

Hi, I was about to reply it like 3-4 times, but I haven’t had time :frowning:

If it’s a side-platformer, flip the sprite is the way to make the enemy look at left or right. If it’s a top-down, you could rotate the sprite, though.
To shoot the bullets, you could check if the enemy is flipped, if it’s flipped shoot the bullets in the oppsite direction ( - 300 ). Also, you are using the Bullet force in X as an angle, when you create an object its forces are 0, so Bullet.ForceX() is 0, then the angle is 0 and you always shoot the bullet to the right (unless you use negative foce length to shoot to the left as I said).

About the GoLeft, GoRight, you could delete 1 event only, doing something like:

[code]Conditions: Enemy is in collision with GoLeft
Actions: Do = -1 to the variable GoEnemy of Enemy
Flip horizontally Enemy: no

Conditions: Enemy is in collision with GoRight
Actions: Do = 1 to the variable GoEnemy of Enemy
Flip horizontally Enemy: yes

Conditions: Variable GoEnemy of Enemy is = 1 OR Variable GoEnemy of Enemy is = -1
Actions: Add to Enemy a force of Enemy.Variable(GoEnemy)*40 on X and 0 on Y[/code]
The events use the value of the GoEnemy variable to set the force direction.

Yes, probably you have another event that is changing the player animation at the same time, one animation reset the other :slight_smile:
To play this 2-animations system (charging and channeling), you could do something like this:

[code]Conditions: Key “K” is pressed
Trigger once
Actions: Do = 3 (charging) to the animation of Player

Conditions: Key “K” is pressed
Animation of Player is = 3
Animation of Player has finished
Actions: Do = 4 (channeling) to the animation of Player[/code]
You can set the animation 3 as non-looping, so when it has finished don’t restart it; and set the animation 4 as looping because… eh… you know.
Also, make sure there is no other event switching the animation while the player is charging.

About the bar, maybe you are using the TimeDelta in a wrong way?, if you want a value to be a function of the time, you should multiply it by TimeDelta:

Do + TimeDelta()*0.6 to the variable Drauf

With this action, the variable Drauf will be increased by 0.6 per second, so you probably want a bigger number, as TimeDelta()*36, to increase the variable by 36 per second :wink:

If you want to cap a value you can use the min/max functions:

Conditions: Key "K" is pressed Actions: Do + TimeDelta()*0.6 to the variable Drauf Do = min(Variable(Drauf), 250) to the variable Drauf
This way Drauf won’t be greater than 250, if you want the variable Drauf to be in the range [0, 250], you can do it in a single event:

Conditions: Key "K" is pressed Actions: Do = max( min( Variable(Drauf)+TimeDelta()*0.6, 250), 0) to the variable Drauf
(lots of spaces to make it more readable)

Thank you so much! I learned a lot more the last days but this still helps heaps.
Cheers! :slight_smile: