GitHub
4 年前
当前提交
faf70fc8
共有 7 个文件被更改,包括 1134 次插入 和 38 次删除
-
15UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/SlimeCritter.controller
-
86UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab
-
1001UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/Attack.anim
-
8UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/Attack.anim.meta
-
8UOP1_Project/Assets/ProBuilder Data.meta
-
43UOP1_Project/Assets/Scripts/Characters/SlimeCritterAttackController.cs
-
11UOP1_Project/Assets/Scripts/Characters/SlimeCritterAttackController.cs.meta
1001
UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/Attack.anim
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 051e79817c3456c48bf1136efa5911d7 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 58345f283dec33746a86a59526b7c070 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class SlimeCritterAttackController : MonoBehaviour |
|||
{ |
|||
// Reference of the player transform to compute the propel target position
|
|||
[SerializeField] |
|||
private TransformAnchor _playerTransform; |
|||
|
|||
// Propel factor is the proportion of the distance between the critter and the player crossed by the critter during the propel animation
|
|||
[SerializeField] |
|||
private float _propelFactor = 1.0f; |
|||
|
|||
// Duration of the propel section of the animation.
|
|||
[SerializeField] |
|||
private float _propelDuration = 0.2f; |
|||
|
|||
private float _innerTime = 0.0f; |
|||
private Vector3 _propelTargetVector = default; |
|||
|
|||
// When the attack starts, the position targeted by the attack is determined and is not changed afterward
|
|||
public void SetAttackTarget() |
|||
{ |
|||
_propelTargetVector = (_playerTransform.Transform.position - transform.position) * _propelFactor / _propelDuration; |
|||
} |
|||
|
|||
// Trigger the propel movement during the attack
|
|||
public void AttackPropelTrigger() |
|||
{ |
|||
_innerTime = _propelDuration; |
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
if (_innerTime > 0) |
|||
{ |
|||
transform.position += _propelTargetVector * Time.deltaTime; |
|||
_innerTime -= Time.deltaTime; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 95216bcd641df05419665f7db9aed05b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue