浏览代码

New code for Impulse listening on collisions

/2019.3-marc
Marc Tanenbaum 4 年前
当前提交
b4ce04aa
共有 3 个文件被更改,包括 77 次插入4 次删除
  1. 48
      Assets/Scripts/Camera/CinemachineImpulseDebugListener.cs
  2. 22
      Assets/Scripts/Camera/EngineCameraState.cs
  3. 11
      Assets/Scripts/Camera/EngineCameraState.cs.meta

48
Assets/Scripts/Camera/CinemachineImpulseDebugListener.cs


namespace Camera
using UnityEngine;
namespace Cinemachine
public class CinemachineImpulseDebugListener
/// <summary>
/// An extension for Cinemachine Virtual Camera which listens for CinemachineImpulse
/// signals on the specified channels, and outputs debug information to console when received
/// </summary>
[SaveDuringPlay]
[AddComponentMenu("")] // Hide in menu
#if UNITY_2018_3_OR_NEWER
[ExecuteAlways]
#else
[ExecuteInEditMode]
#endif
public class CinemachineImpulseDebugListener : CinemachineExtension
/// <summary>
/// Impulse events on channels not included in the mask will be ignored.
/// </summary>
[Tooltip("Impulse events on channels not included in the mask will be ignored.")]
[CinemachineImpulseChannelProperty]
public int m_ChannelMask = 1;
/// <summary>
/// Enable this to perform distance calculation in 2D (ignore Z).
/// </summary>
[Tooltip("Enable this to perform distance calculation in 2D (ignore Z)")]
public bool m_Use2DDistance = false;
protected override void PostPipelineStageCallback(
CinemachineVirtualCameraBase vcam,
CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
{
if (stage == CinemachineCore.Stage.Aim)
{
Vector3 impulsePos = Vector3.zero;
Quaternion impulseRot = Quaternion.identity;
if (CinemachineImpulseManager.Instance.GetImpulseAt(
state.FinalPosition, m_Use2DDistance, m_ChannelMask, out impulsePos, out impulseRot))
{
Debug.Log("CinemachineImpulseDebugListener on: "+gameObject.name+" got impulse"+Quaternion.Angle(impulseRot,Quaternion.identity).ToString("F5")+" "+impulsePos.magnitude.ToString("F5"));
}
}
}
}
}

22
Assets/Scripts/Camera/EngineCameraState.cs


using System.Collections;
using System.Collections.Generic;
using BoatAttack;
using UnityEngine;
namespace Boat
{
public class EngineCameraState : MonoBehaviour
{
public Engine engine;
public Animator anim;
// private int slowHash = Animator.StringToHash("Main.Slow");
// private int fastHash = Animator.StringToHash("Main.Fast");
void Update()
{
anim.SetFloat("EngineSpeed", engine.VelocityMag);
}
}
}

11
Assets/Scripts/Camera/EngineCameraState.cs.meta


fileFormatVersion: 2
guid: 6f895dcd0fa9e40b18253a3ca46c4d78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存