30 lines
986 B
C#
30 lines
986 B
C#
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Add to a weapon prefab to define how it sits in the player's hands.
|
|
/// WeaponManager reads these values when the weapon is equipped.
|
|
/// </summary>
|
|
public class WeaponViewmodel : MonoBehaviour
|
|
{
|
|
[Header("View Model Transform")]
|
|
public Vector3 positionOffset = new Vector3(0.2f, -0.25f, 0.45f);
|
|
public Vector3 rotationOffset = new Vector3(0f, 0f, 0f);
|
|
public Vector3 scale = new Vector3(1f, 1f, 1f);
|
|
|
|
// Called by WeaponManager to apply these values
|
|
public void Apply()
|
|
{
|
|
transform.localPosition = positionOffset;
|
|
transform.localRotation = Quaternion.Euler(rotationOffset);
|
|
transform.localScale = scale;
|
|
}
|
|
|
|
// Called by WeaponManager to sync back after gizmo editing
|
|
public void SyncFromTransform()
|
|
{
|
|
positionOffset = transform.localPosition;
|
|
rotationOffset = transform.localRotation.eulerAngles;
|
|
scale = transform.localScale;
|
|
}
|
|
}
|