-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил врага который follow you
- Loading branch information
Showing
7 changed files
with
59 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extends Area2D | ||
|
||
|
||
|
||
func _on_Body_area_entered(area): | ||
var groups = area.get_groups() | ||
if (groups.has("player")): | ||
$"../".attack() | ||
|
||
|
||
func _on_Body_area_exited(area): | ||
var groups = area.get_groups() | ||
if (groups.has("player")): | ||
$"../".stop_attack() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
extends KinematicBody2D | ||
|
||
var IsPlayerNear = false | ||
var SPEED = 120 | ||
var PlayerPos = Vector2(0,0) | ||
|
||
var SPEED = 150 | ||
func _physics_process(delta): | ||
if(IsPlayerNear == true): | ||
PlayerPos.x = $"../../../../KinematicPlayer".global_position.x - self.global_position.x | ||
PlayerPos.y = $"../../../../KinematicPlayer".global_position.y - self.global_position.y | ||
var motion = PlayerPos.normalized() * SPEED | ||
move_and_slide(motion, Vector2(0,0)) | ||
|
||
|
||
|
||
func _physics_process(delta): | ||
|
||
var MOVE = Vector2() | ||
var body = get_node("Body").get_overlapping_bodies() | ||
func attack(): | ||
IsPlayerNear = true | ||
|
||
if(body.size() != 0): | ||
for tinge in body: | ||
if(tinge.is_in_group("player")): | ||
print('kek') | ||
#if(tinge.global_position().x < self.global_position().x): | ||
# print('good') | ||
func stop_attack(): | ||
IsPlayerNear = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters