Radical, i got that going (threw in an OnImpact callback to make it flinch on damage) and it lurches away, then drifts back. It's actually alot like some dotween hitshakes i've done before. Imma put it on the arrow, then a thrown spear, adn in general see what i can get away with. if it's as useful a bit of procgen anim as it seems, then that could shortcut alot of "make thing wiggle when hit" without needing ot make custom anims or scripts.
Much appreciated! Like i mentioned when UCC is updated next i really recommend you just throw something like this in there. in the demo fuck, put it ON the arrow and just have a bool toggle for if it should activate or not. put a floating target out in the free roam area that shakes when shot or somehting, ect. the springs ya'll made are a huge selling point and it very much seems like that area is being wildly under advertised.
Hell, just put exactly this script in the spring documention. it's simple but it gets some of the idea across.
using UnityEngine;
using Opsive.UltimateCharacterController.Motion;
using Opsive.Shared.Events;
public class TestObjectSpring : MonoBehaviour
{
public void Awake()
{
EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
public Spring spring;
void Start() {
spring.Initialize(false, false);
}
void LateUpdate() {
transform.localPosition = spring.Value;
}
private void OnImpact(float amount, Vector3 position, Vector3 forceDirection, GameObject attacker, object attackerObject, Collider hitCollider)
{
Debug.Log(name + " impacted by " + attacker + " on collider " + hitCollider + ".");
spring.AddForce(forceDirection);
}
public void OnDestroy()
{
Debug.Log("aaa");
EventHandler.UnregisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
}
The fpsitemperspective and ect scripts DO show it in a complex use, but there's so much going on in that script that actualy parsing out what individually is happening is tough. this is simple but i get it and have ideas about how to expand it.
anyway, much appreciated!