技能碰撞改回物理碰撞
This commit is contained in:
@@ -37,7 +37,6 @@ export class SkillCom extends CCComp {
|
||||
animName: string = "";
|
||||
group:number = 0; //阵营
|
||||
fac:number=0; //阵营
|
||||
target:any=null;
|
||||
caster:any=null;
|
||||
distance_x:number=0;
|
||||
distance_y:number=0;
|
||||
@@ -58,32 +57,31 @@ export class SkillCom extends CCComp {
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
let dir_x = this.target.node.position.x > this.node.position.x ? 1 : -1
|
||||
let dir_x = this.targetPos.x > this.node.position.x ? 1 : -1
|
||||
this.node.scale = v3(dir_x,1,1)
|
||||
// 根据目标位置设置节点朝向
|
||||
if (this.target && this.target.node) {
|
||||
if ( this.targetPos) {
|
||||
// 计算朝向
|
||||
let direction = this.target.node.position.x > this.node.position.x ? 1 : -1;
|
||||
let direction = this.targetPos.x > this.node.position.x ? 1 : -1;
|
||||
// 设置节点缩放来改变朝向
|
||||
this.node.scale = v3(direction * Math.abs(this.scale), this.scale, 1);
|
||||
}
|
||||
let dir_y = (this.target.node.position.y+BoxSet.ATK_Y) > this.node.position.y ? 1 : -1
|
||||
if(this.target.node.position.y+BoxSet.ATK_Y==this.node.position.y){
|
||||
let dir_y = ( this.targetPos.y+BoxSet.ATK_Y) > this.node.position.y ? 1 : -1
|
||||
if( this.targetPos.y+BoxSet.ATK_Y==this.node.position.y){
|
||||
dir_y=0
|
||||
}
|
||||
// 计算这一帧的移动距离
|
||||
this.distance_x = SkillSet[this.s_uuid].speed*dir_x;
|
||||
this.distance_y = this.distance_x*Math.abs(this.target.node.position.y-this.node.position.y)/Math.abs(this.target.node.position.x-this.node.position.x)*dir_y;
|
||||
this.distance_y = this.distance_x*Math.abs(this.targetPos.y-this.node.position.y)/Math.abs(this.targetPos.x-this.node.position.x)*dir_y;
|
||||
this.startMovement();
|
||||
|
||||
// 计算目标角度
|
||||
if (this.target && this.target.node) {
|
||||
const targetPos = this.target.node.position;
|
||||
if (this.targetPos) {
|
||||
const currentPos = this.node.position;
|
||||
|
||||
// 计算角度(弧度)
|
||||
const dx = targetPos.x - currentPos.x;
|
||||
const dy = (targetPos.y + BoxSet.ATK_Y) - currentPos.y;
|
||||
const dx = this.targetPos.x - currentPos.x;
|
||||
const dy = (this.targetPos.y + BoxSet.ATK_Y) - currentPos.y;
|
||||
const angle = Math.atan2(dy, dx);
|
||||
|
||||
// 将弧度转换为角度并设置节点旋转
|
||||
|
||||
Reference in New Issue
Block a user