mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 00:15:54 +00:00
Fix for barrels not exploding properly in tilemaps
This commit is contained in:
parent
f0b93f467c
commit
0eb6a9140f
5 changed files with 44 additions and 37 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Cirno.Scripts;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -50,18 +51,21 @@ public partial class Enemy : Area2D
|
|||
return;
|
||||
}
|
||||
|
||||
if (IsPlayerInSight()) {
|
||||
if (IsPlayerInSight())
|
||||
{
|
||||
// SHOOT
|
||||
var bullet = BulletScene.Instantiate<Bullet>();
|
||||
Owner.AddChild(bullet);
|
||||
bullet.Transform = this.GlobalTransform;
|
||||
bullet.Position = this.Position;
|
||||
var bullet = this.CreateChild<Bullet>(BulletScene);
|
||||
// var bullet = BulletScene.Instantiate<Bullet>();
|
||||
// Owner.AddChild(bullet);
|
||||
// bullet.Transform = this.GlobalTransform;
|
||||
// bullet.Position = this.Position;
|
||||
bullet.SetDirection((_cachedPlayer.GlobalPosition - this.GlobalPosition).Normalized());
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPlayerInSight() {
|
||||
var spaceState = GetWorld2D().DirectSpaceState;
|
||||
private bool IsPlayerInSight()
|
||||
{
|
||||
var spaceState = GetWorld2D().DirectSpaceState;
|
||||
var query = PhysicsRayQueryParameters2D.Create(this.GlobalPosition, _cachedPlayer.GlobalPosition, CollisionMask, new Godot.Collections.Array<Rid> { GetRid() });
|
||||
var result = spaceState.IntersectRay(query);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue