2
0
Fork 0

弹墙优化

master
cd 2 years ago
parent eb6b465126
commit e5a31a89f6

@ -877,63 +877,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &809832855
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1464602466083886, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_Name
value: effect_cast_ground01
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalPosition.z
value: -1
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3}
--- !u!1001 &1015172259
PrefabInstance:
m_ObjectHideFlags: 0
@ -1761,72 +1704,72 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &6855760895463423098
--- !u!1001 &3695570339981591418
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4239479062022509658, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3696463158923097795, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_Name
value: effect_hit_ground01
value: effect_hit_wall01
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_RootOrder
value: 13
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalPosition.x
value: -1.721
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.001
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: -1
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8,
- target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2f61d8469e470a04b8a91b91557e71e8, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3}

@ -136,10 +136,16 @@ namespace Game
return Vector3.zero;
}
if (e.move.IsFlowing && e.hasHp)
{
return e.hp.LastDamageDir;
}
if (e.hasPause && e.pause.IsPause)
{
return e.pause.VelocityCache;
}
return e.move.Velocity;
}

@ -19,8 +19,8 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem
{
CheckHit(entity); //打射线 检查角色四周是否有阻挡 是否在地面
TurnUpdate(entity.move); //更新转向
ReboundUpdate(entity); //更新落地反弹
ReboundWallUpdate(entity); //更新撞墙反弹
ReboundUpdate(entity); //更新落地反弹
}
}
@ -121,6 +121,8 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem
Util.CastGroundStaticEffect(GameConst.EffectHitGround1, entity.ID());
//卡帧
Util.EntityPause(entity, 0.05f);
//抖动
Util.EntityShake(entity, 2);
//缩放
Util.EntityScale(entity, Vector3.right * 6);
}
@ -149,30 +151,35 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem
if (Util.HasSetSpeedBuff(entity.ID()))
{
//撞墙反弹-大
Util.RemoveHitDownBuff(entity.ID());
Util.RemoveSetSpeedBuff(entity.ID());
move.Velocity = new Vector3(-move.Velocity.x, 6, -move.Velocity.z);
//反弹方向xz沿CrashWallNormal,值为当前速度钳制[2,10]
var speed = new Vector3(move.Velocity.x, 0, move.Velocity.z).magnitude;
speed = Mathf.Clamp(speed, 2, 10);
var velocity = move.CrashWallNormal * speed;
move.Velocity = new Vector3(velocity.x, 6, velocity.z);
if (entity.hasAnimation)
{
entity.animation.AirHitMsg = true;
}
if (Util.HasHitDownBuff(entity.ID()))
{
Util.RemoveHitDownBuff(entity.ID());
}
//撞墙反弹特效
Util.CastWallStaticEffect(GameConst.EffectHitWall1, entity.ID(), move.CrashWallPosition,
move.CrashWallNormal);
//卡帧
Util.EntityPause(entity, 0.05f);
//抖动
Util.EntityShake(entity, 2);
//缩放
Util.EntityScale(entity, Vector3.up * 6);
}
else
{
//撞墙反弹-小
move.Velocity = new Vector3(-move.Velocity.x, move.Velocity.y, -move.Velocity.z);
var speed = new Vector3(move.Velocity.x, 0, move.Velocity.z).magnitude;
speed = Mathf.Clamp(speed, 2, 3);
var velocity = move.CrashWallNormal * speed;
move.Velocity = velocity;
//撞墙特效
Util.CastWallStaticEffect(GameConst.EffectHitWall2, entity.ID(), move.CrashWallPosition,
move.CrashWallNormal);
@ -185,28 +192,29 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem
{
var move = entity.move;
var view = entity.view;
RaycastHit hitInfo;
var bodySize = view.Collider.bounds.size;
const float checkOffset = 0.1f;
const float checkLength = 0.2f;
//检查落地
move.IsGround = Physics.Raycast(move.Position + Vector3.up * checkOffset, Vector3.down, out hitInfo,
checkLength, UtilPhysics.LayerMaskDefault);
var checkDir = Vector3.down;
var startPos = move.Position + Vector3.up * checkOffset;
move.IsGround = Physics.Raycast(startPos, checkDir, out var hitInfo, checkLength, UtilPhysics.LayerMaskDefault);
move.IsGroundLogic = move.IsGround && move.JumpState == EJumpState.OnGround;
if (move.IsGround)
{
move.GroundPosition = hitInfo.point;
}
Util.Draw(move.Position + Vector3.up * checkOffset,
move.Position + Vector3.up * checkOffset + Vector3.down * checkLength, Color.green);
Util.Draw(startPos, startPos + checkDir * checkLength, move.IsGround ? Color.red : Color.green);
//检查移动贴墙
var checkDir = move.MoveDir;
var startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset);
checkDir = move.MoveDir;
startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset);
move.IsAgainstWall = Physics.Raycast(startPos, checkDir, out hitInfo, checkLength, UtilPhysics.LayerMaskWall);
Util.Draw(startPos, startPos + checkDir * checkLength, move.IsAgainstWall ? Color.red : Color.green);
//检查冲撞贴墙
checkDir = move.Velocity.normalized;
startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset);
@ -217,6 +225,6 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem
move.CrashWallNormal = hitInfo.normal;
}
Util.Draw(startPos, startPos + checkDir * checkLength, move.IsAgainstWall ? Color.red : Color.green);
Util.Draw(startPos, startPos + checkDir * checkLength, move.IsCrashToWall ? Color.red : Color.green);
}
}

@ -296,7 +296,16 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
//命中瞬间、在pause之前生效部分位移
var move = target.move;
move.Transform.position += flowSpeed * Time.deltaTime * 2;
var posAdd = flowSpeed * Time.deltaTime * 2;
var targetPos = move.Position + posAdd;
var startPos = move.Position - posAdd.normalized * 0.001f;
RaycastHit raycastHit;
if (Physics.Raycast(startPos, posAdd, out raycastHit, posAdd.magnitude, UtilPhysics.LayerMaskStatic))
{
targetPos = raycastHit.point;
}
move.Position = targetPos;
return flowSpeed;
}

@ -212,8 +212,6 @@ namespace Game
// 墙面特效:在实体对应地面播放,跟随实体暂停/销毁 但是不跟随移动
public static void CastWallStaticEffect(string effectId, int targetEntity, Vector3 pos, Vector3 normal)
{
// 忽略normal的y轴 保证特效垂直于墙面
normal.y = 0;
var rot = Util.Vec3ToRot(normal);
CastEffect(effectId, pos, rot, targetEntity, 0, false);
}

@ -16,5 +16,6 @@ namespace Game
public static readonly int LayerMaskPlayer = 1 << LayerPlayer;
public static readonly int LayerMaskMonster = 1 << LayerMonster;
public static readonly int LayerMaskCharacter = LayerMaskPlayer | LayerMaskMonster;
public static readonly int LayerMaskStatic = LayerMaskDefault | LayerMaskWall;
}
}

@ -648,7 +648,7 @@ MonoBehaviour:
isRaycast: 0
center: {x: 1, y: 1, z: 0}
halfExtents: {x: 1.5, y: 1, z: 0.5}
flowSpeed: {x: 1, y: 2, z: 0}
flowSpeed: {x: 1, y: 1, z: 0}
flowTime: 0
isFlow: 0
damageRate: 0.5

@ -692,7 +692,7 @@ MonoBehaviour:
isRaycast: 0
center: {x: 1, y: 1, z: 0}
halfExtents: {x: 1.5, y: 1, z: 0.5}
flowSpeed: {x: 3, y: 1, z: 0}
flowSpeed: {x: 2, y: 1, z: 0}
flowTime: 0
isFlow: 0
damageRate: 1

@ -585,7 +585,7 @@ MonoBehaviour:
isRaycast: 0
center: {x: 1, y: 1, z: 0}
halfExtents: {x: 1.5, y: 1, z: 0.5}
flowSpeed: {x: 2, y: 0, z: 0}
flowSpeed: {x: 3, y: 1, z: 0}
flowTime: 0
isFlow: 0
damageRate: 0.5

Loading…
Cancel
Save