Distance to Death

本文探讨了生命与死亡之间的距离,作者尝试理解死亡并反思未完成的事物,表达了对责任感的理解及对上帝信仰的看法。

What do you think of the distance to death? Is it long? Is it short? Have you ever try to get in touch with it?

Life is short, death is close. When body and spirit are separated from each other, life ends. When you arechoked formore than 5 minutes, life ends. When a bus knocks into you, life ends. When God want to see you, life ends.

I triedto get in touch with it, but failed at last. Iwasnot breave enough. I have so many things unfinished. There's a voice told me to take the responsibility and finish all the things. Are these things really need to finish? And what if I ignore them? Maybe, things will befarawayfrom our expectation. But do believe God manages all.

Event Names Here is a list of all EventHandler events that the controller uses, along with a brief description of what each event is used for and its parameters, if it has any: Event Name Parameters Description OnAbilityActive Ability ability, bool active The has started or stoppedability OnAbilityMessageCanStart Ability ability, bool canStart The can start or no longer stop.ability OnAbilityUnequipItemComplete CharacterItem item, int slotID The has been unequipped from the slot .itemslotID OnAbilityWillEquipItem CharacterItem item, int slotID The will be equipped in the slot .itemslotID OnAddCrosshairsSpread bool start, bool fromRecoil The crosshair spread should be started/stopped, either from recoil or set to max spread. OnAddSecondaryCameraForce Vector3 positionalForce, Vector3 rotationalForce, float restAccumulation Adds a secondary positional and rotational force to the ViewTypes. OnAddSecondaryForce int slotID, Vector3 positionalForce, Vector3 rotationalForce, bool globalForce Adds a positional and rotational force to the IK target. OnAimAbilityAim bool aim The aim ability is/is not aiming. OnAimAbilityStart bool aim, bool inputStart The aim ability was started/stopped. describes whether it was started/stopped from user input.inputStart OnAnimatorSnapped The animator has been snapped. OnAnimatorWillSnap The animator will snap. OnAnchorOffsetUpdated The camera’s anchor offset value has been changed. OnAttributeModifierAutoUpdateEnabled AttributeModifier attributeModifier, bool enable The ‘s auto-update has been enabled/disabled.attributeModifier OnAttributeReachedDestinationValue An attribute has reached its destination value. OnAttributeUpdateValue Attribute attribute The ‘s value has been changed.attribute OnCameraAttachCharacter GameObject character The has been attached to the camera.character OnCameraChangePerspectives bool firstPersonPerspective The camera has swithced between first and third person perspectives. OnCameraChangeViewTypes ViewType viewType, bool activate The was activated/deactivated.viewType OnCameraRotationalForce Vector3 force Add the rotational to the camera.force OnCameraWillChangePerspectives bool firstPersonPerspective The camera will switch between first and third person perspectives. OnCameraZoom bool zoom The camera has zoomed in/out. OnCharacterAbilityActive Ability ability, bool active The has been activated/deactivated.ability OnCharacterActivate bool active The character itself has been activated/deactivated. OnCharacterAttachCamera CameraController cameraController The has been attached to the character.cameraController OnCharacterAttachLookSource ILookSource lookSource The has been attached to the character.ILookSource OnCharacterChangeMovementType MovementType movementType The character’s movement type will be changed to .movementType OnCharacterChangeMovingPlatforms Transform platform The character has been attached to the moving .platform OnCharacterChangePerspectives bool firstPersonPerspective The camera will switch between first and third person perspectives. OnCharacterChangeTimeScale bool value The character’s time scale will be changed to .value OnCharacterChangeUpdateLocation UpdateLocation updateLocation The character’s update location will be changed to the specified .updateLocation OnCharacterDestroyed The Ultimate Character Locomotion component has been destroyed. OnCharacterEnterUIZone bool inUIZone The character has entered/exited a zone which should show the UI and cursor. OnCharacterForceIndependentLook bool independentLook Independent look will be enabled/disabled on the character to allow the ability to have control over rotation. OnCharacterGrounded bool grounded The character’s grounded state has changed to .grounded OnCharacterImmediateTransformChange bool snapAnimator The character’s transform position/rotation has been immediately changed. OnCharacterIndependentFade bool enable, bool revertFade Another object has started or stopped taking control of the character fade. OnCharacterItemAbilityActive ItemAbility itemAbility, bool active The has been activated/deactivated.itemAbility OnCharacterLand float height The character has landed from .height OnCharacterLean float distance, float tilt, float itemTiltMultiplier The character is leaning the specified and amount.distancetilt OnCharacterMoving bool moving The character has either started or stopped moving. OnCharacterSnapAnimator The character’s animator should be snapped to match its current state. OnDeath Vector3 position, Vector3 force, GameObject attacker An object with the Health component has died. See .OnHealthDamage OnEnableGameplayInput bool enable Gameplay input should be enabled/disabled. OnEquipUnequipItemSetIndexChange int itemSetIndex The active ItemSet index has changed to .itemSetIndex OnEquipUnequipVerifyUnequipItem int itemSetCategoryIndex, int slotID Verify that the unequipping item specified by the in the slot still needs to be unequipped.itemSetCategoryIndexslotID OnFirstPersonPerspectiveActivate FirstPersonPerspectiveItem perspectiveItem, bool active The first person perspective item has been activated/deactivated. OnHealthDamage float amount, Vector3 position, Vector3 force, GameObject attacker, Collider hitCollider Damage has been applied to the Health component. OnHealthHeal float amount The Health component has been healed by .amount OnHeightChangeAdjustHeight float heightAdjustment The character’s height has been adjusted by the specified amount. OnInputControllerConnected bool controllerConnected A controller has been connected/disconnected. OnInventoryAddItem CharacterItem item The has been added to the inventory.item OnInventoryAdjustItemIdentifierAmount IItemIdentifier itemIdentifier, int remaining The amount of the item has been adjusted, leaving of that item left.itemIdentifierremaining OnInventoryEquipItem CharacterItem item, int slotID The in slot has been equipped.itemslotID OnInventoryPickupItem CharacterItem item, int amount, bool immediatePickup, bool forceEquip The of has been picked up and will/will not be picked up immediately and forcefully equipped.amountitem OnInventoryPickupItemIdentifier IItemIdentifier itemIdentifier, int amount, bool immediatePickup, bool forceEquip The of item has been picked up and will/will not be picked up immediately and forcefully equipped.amountitemIdentifier OnInventoryRemoveItem OnInventoryRespawned The inventory has respawned. OnInventoryUnequipItem CharacterItem item, int slotID The in slot has been unequipped.itemslotID OnItemPickupStartPickup An ItemPickup has been started to be picked up. OnItemPickupStopPickup An ItemPickup has been stopped to be picked up. OnItemSetIndexChange int categoryIndex, int itemSetIndex The ItemSetManager has changed the category ‘s active ItemSet index to .categoryIndexitemSetIndex OnItemSetManagerUpdateItemSet int categoryIndex, int itemSetIndex Updates the currently active item set in the category to .categoryIndexitemSetIndex OnItemSetManagerUpdateNextItemSet int categoryIndex, int prevItemSetIndex, int itemSetIndex Updates the next item set in category , including the previous and next item set indices.categoryIndex OnItemShowFullScreenUI int fullScreenUIID, bool showFullScreenUI Shows/hides the full screen UI object based on its UI ID. OnItemStartUse IUsableItem item, bool use The is starting/stopping use.item OnItemTryReload int slotID, IItemIdentifier itemIdentifier, bool immediateReload, bool equipCheck The item at slot is trying to reload using .slotIDitemIdentifier OnItemUpdateDominantItem CharacterItem item, bool dominantItem Sets the as the dominant/not dominant item.item OnMagicItemCast CharacterItem item The magic has cast an action.item OnMagicItemImpact CharacterItem item, SurfaceImpact surfaceImpact The magic has collided with a surface.item OnMagicItemStartStopBeginEndActions CharacterItem item, bool beginActions, bool start A magic ‘s begin/end actions have been started/stopped.item OnNextItemSet CharacterItem item, bool unequipOnFailure The wants to change to equip the next item from the item set.item OnObjectImpact ImpactCallbackContext ctx An object has been impacted by another object. OnObjectPickedUp ObjectPickup objectPickup The has been picked up.objectPickup OnRespawn The object has respawned. OnShieldImpact Shield shield, object source The has been impacted by .shieldobject OnShootableWeaponShowProjectile GameObject projectile, bool show The ShootableWeapon ItemAction has shown or hidden a .projectile OnShowUI bool show The UI should be shown/hidden. OnStateChange GameObject gameObject, string stateName, bool active The has activated/deactivated the state.gameObjectstateName OnStoredInputAbilityResetStoredInputs Resets the ability’s stored user inputs. OnTryRecenterTracking VR only – The camera’s rotation has changed, so tracking recentering should occur. OnUseAbilityStart bool start, Use useAbility The specified has been started/stopped.useAbility OnUseAbilityUsedItem IUsableItem item The Use ability has used .item OnWillRespawn The object will respawn.把这些和上面的结合起来看,如果我要监控某一个Ability的启动怎么处理
09-30
using UnityEngine; using UnityEngine.AI; public class RGEnemyController : MonoBehaviour { public RGPlayerController playerController; // 确保在Unity编辑器中拖拽赋值 [Header("敌人动画控制器")] public Animator animator; [Header("敌人状态")] public RGPlayerState state = RGPlayerState.idle; [Header("移动参数")] public float moveSpeed = 4.5f; // 敌人移动速度 public float stopDistance = 1.5f; // 停止移动距离 public float reEngageDistance = 3f; // 重新追击距离 public float atkDistance = 0.5f; // 攻击距离 // 是否在追击状态 private bool isChasing = false; [Header("物理参数")] public Rigidbody rb; // 刚体组件 public float collisionCheckDistance = 1f; // 碰撞检测距离 public LayerMask obstacleLayers; // 障碍物层级 void Start() { // 确保有刚体组件 if (rb == null) rb = GetComponent<Rigidbody>(); if (rb == null) rb = gameObject.AddComponent<Rigidbody>(); // 配置刚体物理属性 rb.constraints = RigidbodyConstraints.FreezeRotation; // 锁定旋转 rb.useGravity = false; // 根据需求决定是否启用重力 // 确保有动画控制器 if (animator == null) animator = GetComponentInChildren<Animator>(); } void FixedUpdate() { if (state == RGPlayerState.death) return; Move(); } void Move() { // 计算到玩家的距离 float distance = Vector3.Distance(transform.position, playerController.transform.position); // 1. 进入追击状态的条件 if (distance > reEngageDistance) { isChasing = true; } // 2. 停止追击的条件 else if (distance < stopDistance) { isChasing = false; } // 追击逻辑 if (isChasing) { // 在追击距离和停止距离之间移动 if (distance > stopDistance) { SetState(RGPlayerState.run); // 计算移动方向 Vector3 moveDirection = (playerController.transform.position - transform.position).normalized; moveDirection.y = 0; // 保持水平移动 // 碰撞检测:检查前方是否有障碍物 if (!Physics.Raycast(transform.position, moveDirection, collisionCheckDistance, obstacleLayers)) { // 通过刚体物理移动(触发碰撞检测) rb.velocity = moveDirection * moveSpeed; transform.rotation = Quaternion.LookRotation(moveDirection); } else { // 遇到障碍物时停止移动 rb.velocity = Vector3.zero; // 这里可以添加绕行逻辑 } } else { rb.velocity = Vector3.zero; SetState(RGPlayerState.idle); } } // 攻击逻辑 else { rb.velocity = Vector3.zero; // 停止移动 if (distance <= atkDistance) { SetState(RGPlayerState.attack); } else { SetState(RGPlayerState.idle); } } } void SetState(RGPlayerState newState) { if (state == newState) return; state = newState; // 设置动画参数 animator.SetBool("isRun", state == RGPlayerState.run); animator.SetBool("isAttack", state == RGPlayerState.attack); // 注意:确保动画控制器中有对应的参数(isRun和isAttack) } // 攻击动画事件回调 public void OnAttackEnter(AnimatorStateInfo stateInfo, Animator animator) { Debug.Log("敌人攻击"); // 确保playerController有BeAttacked方法 playerController.BeAttacked(1); } } 把这个脚本的移动改成由NavMesh控制,而动画控制不变
12-06
【电动汽车充电站有序充电调度的分散式优化】基于蒙特卡诺和拉格朗日的电动汽车优化调度(分时电价调度)(Matlab代码实现)内容概要:本文介绍了基于蒙特卡洛和拉格朗日方法的电动汽车充电站有序充电调度优化方案,重点在于采用分散式优化策略应对分时电价机制下的充电需求管理。通过构建数学模型,结合不确定性因素如用户充电行为和电网负荷波动,利用蒙特卡洛模拟生成大量场景,并运用拉格朗日松弛法对复杂问题进行分解求解,从而实现全局最优或近似最优的充电调度计划。该方法有效降低了电网峰值负荷压力,提升了充电站运营效率与经济效益,同时兼顾用户充电便利性。 适合人群:具备一定电力系统、优化算法和Matlab编程基础的高校研究生、科研人员及从事智能电网、电动汽车相关领域的工程技术人员。 使用场景及目标:①应用于电动汽车充电站的日常运营管理,优化充电负荷分布;②服务于城市智能交通系统规划,提升电网与交通系统的协同水平;③作为学术研究案例,用于验证分散式优化算法在复杂能源系统中的有效性。 阅读建议:建议读者结合Matlab代码实现部分,深入理解蒙特卡洛模拟与拉格朗日松弛法的具体实施步骤,重点关注场景生成、约束处理与迭代收敛过程,以便在实际项目中灵活应用与改进。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值