Added 2 new enemy movement sets including jumping

This commit is contained in:
=
2026-01-27 09:22:14 -07:00
parent 0506824cf1
commit 4ca341f416
3 changed files with 27 additions and 11 deletions

View File

@@ -50,7 +50,8 @@ public partial class IQEnemy : CharacterBody2D
if (HasMeta("WalkSpeed")) WalkSpeed = (float)GetMeta("WalkSpeed");
else WalkSpeed = 20.0f;
if (HasMeta("JumpHeight")) JumpHeight = (float)GetMeta("JumpHeight");
else JumpHeight = 20.0f;
else JumpHeight = 250.0f;
JumpHeight *= -1;
// Read and set stats
if (HasMeta("MaxHP")) MaxHP = (float)GetMeta("MaxHP");
@@ -78,11 +79,11 @@ public partial class IQEnemy : CharacterBody2D
if (IQ >= 100 && HasMeta("RegenerationInterval")) RegenerationInterval *= 0.9f;
if (IQ >= 100 && HasMeta("RegenerationAmmount")) RegenerationAmmount *= 1.05f; // 5% increase
WalkSpeed += IQ / 20;
JumpHeight += IQ / 30;
WalkSpeed += IQ / 10;
JumpHeight += IQ / 15;
}
public override void _Process(double delta)
public override void _PhysicsProcess(double delta)
{
// Update Timer
GlobalTimer = GetTree().Root.GetNode<CommonData>("CommonData").GlobalTimer;
@@ -97,13 +98,26 @@ public partial class IQEnemy : CharacterBody2D
// Movement
// Add gravity.
if (GroundDetected == false){Velocity = new Vector2(Velocity[0],100);}
if (GroundDetected == false){Velocity = new Vector2(Velocity[0],Velocity[1] + 10);}
if (IQ <= 20){ // Goomba ahh diddy blud
if (IQ >= 0 && IQ <= 20){ // Goomba ahh diddy blud
if (GroundDetected && LedgeDetected == false){Flip();}
if (WallDetected){Flip();}
if (GroundDetected){Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]);} // Walk
}
if (IQ > 20 && IQ <= 30){ // Goomba w/ hopps (no judy)
Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]); // Walk
if (WallDetected && GroundDetected && Velocity[1] == 0){Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump
if (WallDetected && GroundDetected && Velocity[1] > 0){Flip();} // Wall too high
}
if (IQ > 30 && IQ <= 40){ // Adds jumping when reaching edge as feature (also adding directional x force)
if (GroundDetected){Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]);} // Walk on ground
else{Velocity = new Vector2(WalkSpeed * VAH.Scale[0] * 2, Velocity[1]);} // Walk on air
if (WallDetected && GroundDetected && Velocity[1] == 0){Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump
//if (GroundDetected && LedgeDetected == false && Velocity[1] == 0){Velocity = new Vector2(Velocity[0] * 50, JumpHeight);} // Jump at ledge
if (GroundDetected && LedgeDetected == false && Velocity[1] == 0){Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump at ledge
if (WallDetected && GroundDetected && Velocity[1] > 0){Flip();} // Wall too high
}
MoveAndSlide(); // Updates physics applied this frame
}