40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
namespace BITKit
|
||
|
{
|
||
|
public class LocationMixer : BITBehavior
|
||
|
{
|
||
|
[System.Serializable]
|
||
|
struct LocationInfo
|
||
|
{
|
||
|
public Location location;
|
||
|
public float weight;
|
||
|
}
|
||
|
[SerializeField] Dictionary<int, LocationInfo> locations = new();
|
||
|
public void SetLocation(Location location, int index = 0, float weight = 0)
|
||
|
{
|
||
|
locations.Set(index, new()
|
||
|
{
|
||
|
location = location,
|
||
|
weight = weight
|
||
|
});
|
||
|
}
|
||
|
void LateUpdate()
|
||
|
{
|
||
|
Location currentLocation = new();
|
||
|
locations.ForEach(x =>
|
||
|
{
|
||
|
if (x.Key is 0)
|
||
|
{
|
||
|
currentLocation = x.Value.location * x.Value.weight;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
currentLocation=Location.Lerp(currentLocation,x.Value.location,x.Value.weight);
|
||
|
}
|
||
|
});
|
||
|
transform.SetPositionAndRotation(currentLocation, currentLocation);
|
||
|
}
|
||
|
}
|
||
|
}
|