Enemy is consious of relative player location
This commit is contained in:
@@ -241,12 +241,14 @@ tile_set = SubResource("TileSet_q0ben")
|
||||
|
||||
[node name="IQEnemy" parent="Enemies" instance=ExtResource("8_s63xy")]
|
||||
position = Vector2(208, -7)
|
||||
metadata/IQ = 40
|
||||
metadata/IQ = 60
|
||||
|
||||
[node name="IQEnemy2" parent="Enemies" instance=ExtResource("8_s63xy")]
|
||||
visible = false
|
||||
position = Vector2(90, -19)
|
||||
|
||||
[node name="IQEnemy3" parent="Enemies" instance=ExtResource("8_s63xy")]
|
||||
visible = false
|
||||
position = Vector2(115, -83)
|
||||
metadata/IQ = 30
|
||||
|
||||
|
||||
@@ -126,6 +126,17 @@ public partial class IQEnemy : CharacterBody2D
|
||||
#endregion
|
||||
#region 60IQ
|
||||
if (IQ > 40 && IQ <= 60){ // Concious of what side of the enemy the player is on
|
||||
var CurrentLevel = GetTree().Root.GetChildren();
|
||||
float DistanceFromPlayerX = GlobalPosition[0] - CurrentLevel[2].GetNode<Node2D>("Player").GlobalPosition[0];
|
||||
if (DistanceFromPlayerX > (30.0f / (IQ / 4))){ if (VAH.Scale[0] > 0){Flip();}} // left of player
|
||||
if (DistanceFromPlayerX < (-30.0f / (IQ / 4))){ if (VAH.Scale[0] < 0){Flip();}} // right of player
|
||||
|
||||
if (DistanceFromPlayerX < (-30.0f / (IQ / 4)) && GroundDetected && GlobalPosition[0] > CurrentLevel[2].GetNode<Node2D>("Player").GlobalPosition[1]) {Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump when player is overhead
|
||||
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
|
||||
}
|
||||
#endregion
|
||||
#region 80IQ
|
||||
|
||||
Reference in New Issue
Block a user