Skip to content

Improve ghoul behaviour (rebase+fix) #3230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Hypernoot
Copy link
Member

a fixed and rebased version of #2848

@Hypernoot Hypernoot force-pushed the ghoul-behaviour-hypernoot branch from 075ed0d to 58ecade Compare April 7, 2025 18:47
@Hypernoot Hypernoot requested a review from weluvgoatz April 8, 2025 15:50
Copy link
Member

@Frostwithasideofsalt Frostwithasideofsalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seems to be a bug where the ghoul refuses to move until i pass below it at least once.

@Hypernoot Hypernoot force-pushed the ghoul-behaviour-hypernoot branch from 58ecade to 474d246 Compare April 14, 2025 15:37
@Rusty-Box
Copy link
Member

Looking pretty good so far. A few suggestions I have:

  • Have Ghoul thrust more agressivly towards the player than just up at a set angle.
  • If Tux is too far away, I think Ghoul just stop chasing him and simply hover in mid-air waiting.
  • Ghouls stun time could be reduced a little bit.

@Frostwithasideofsalt
Copy link
Member

well it seems my issue with the ghoul not moving is fixed lol

@Hypernoot
Copy link
Member Author

Thanks for review!

* Have Ghoul thrust more agressivly towards the player than just up at a set angle.

Can you please elaborate on what that means in particular?

* If Tux is too far away, I think Ghoul just stop chasing him and simply hover in mid-air waiting.

That is already implemented but the default tracking range is quite large. You can set it to a lower value to actually see it. The default value can be reduced if needed.

* Ghouls stun time could be reduced a little bit.

The stunning time is now 5s. I can reduce it to maybe 3s.

@Rusty-Box
Copy link
Member

Can you please elaborate on what that means in particular?

Currently, when the player is higher than Ghoul, Ghoul does simply push itself relatively straight upwards whlie slowly moving towards him. What I had in mind was closer to the Blooper from Mario, in that instead of going straight up, Ghoul pushes itself towards Tux, so more diagonal-up. They only move with every thrust, standing still before charging up another thrust to move closer to Tux again. Like a jellyfish.

That is already implemented but the default tracking range is quite large. You can set it to a lower value to actually see it. The default value can be reduced if needed.

Nice, I'll have to try out a few values then to find a good default.

The stunning time is now 5s. I can reduce it to maybe 3s.

Try 4. Should be enough.

@Hypernoot
Copy link
Member Author

As you may have noticed, when the ghoul is bellow its target position, he jumps upwards by a defined step. When Tux is above ghoul but not much higher, then a single jump may suffice for the ghoul to reach Tux. If Tux is higher than that, then the ghoul actually makes multiple consecutive jumps to reach Tux. Shall I make the jumps shorter to make it more apparent?

@Rusty-Box
Copy link
Member

Rusty-Box commented May 24, 2025

Shall I make the jumps shorter to make it more apparent?

You could give it a try and I'll give that a look

@Hypernoot
Copy link
Member Author

@Rusty-Box Thanks for input, you can try it now ^.^

@Rusty-Box
Copy link
Member

Yeah, so the horizontal speed is still very low when going up. The idea was that it moves faster horizontally too when it thrusts itself upwards. The speed when it goes down is fine but should have much more speed per thrust horizontally.

@Hypernoot
Copy link
Member Author

@Rusty-Box feel free to check

Copy link
Member

@Frostwithasideofsalt Frostwithasideofsalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/user-attachments/assets/41a62f15-8ab7-43e4-b6ed-0116e0dba26d
there's a bug where a ghoul will sometimes trusts backwards? in which it seems to have no speed cap or something, causing it to go flying

break;
default:
break;
const float vy = (UP_VELOCITY + DOWN_VELOCITY) / 2.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this value I keep seeing? What does it mean? The upwards thrust velocity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the mean velocity of linearly accelerated movement.

{
const float vx = m_physic.get_velocity_x();
const float ax = m_physic.get_acceleration_x();
if (vx * ax > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is vx * ax? The resulting x velocity when affected by the acceleration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tests whether vx and ax have the same sign, similar to the dot product.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (vx * ax > 0) {
if (std::signbit(vx) == std::signbit(ax)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I don't want the condition to trigger when either vx or ax is zero.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright then

@Frostwithasideofsalt
Copy link
Member

ok testing it further, setting the speed really low causes the ghoul to fly backwards. tbh idk why you can even set the speed i think it might be best to just make you not able to edit it?

@Hypernoot
Copy link
Member Author

Good catch! I will remove the speed setting completely, you can't choose the speed of most badguys, so there's no point why this one should be changeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants