Forum rules - please read before posting.

Hotspot when NPC is not idle

https://imgur.com/a/cOjDFgZ

When standing, the hotspot of a NPC is correct, but it stays the same hotspot when an animation makes him laying down, for example.

Can the hotspot be adjusted to the enclosing rectangle of the current animation?

Comments

  • edited July 25

    You can use a custom script to resize the Hotspot's collider to match the current renderer bounds.

    • Replace the Capsule Collider with a Box Collider
    • Check Update When Offscreen in the Skinned Mesh Renderer
    • Attach the script below and assign its variables

    ColliderMatchBounds.cs:

    using UnityEngine;
    
    public class ColliderMatchBounds : MonoBehaviour
    {
    
        public BoxCollider boxCollider;
        public SkinnedMeshRenderer skinnedMeshRenderer;
    
        void Update()
        {
            var worldSize = skinnedMeshRenderer.bounds.size;
            var localSize = new Vector3(worldSize.x / transform.lossyScale.x, worldSize.y / transform.lossyScale.y, worldSize.z / transform.lossyScale.z);
    
            boxCollider.center = transform.InverseTransformPoint(skinnedMeshRenderer.bounds.center);
            boxCollider.size = localSize;
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.