Forum rules - please read before posting.

Player Collider follow direction

Hi, I searched the site but didn't find much on the topic.
I don't know if it's possible, but I'd like to try.
I would like the collider attached to the player (here in the video the green sphere) to follow the direction in which the player turns, so that he can interact with the hotspots only when he is looking at them.
Is this something that can be done without code?

Thank you very much always, the support for this plugin is one of a kind

Comments

  • You'll need to first make sure that the Hotspot Detector and its Collider is on a child of the Player's "sprite child" - so that it can be moved independently of the Player themselves.

    If the Collider is the same as the "root" collider, create a new collider on a new child GameObject - parented to the sprite child - and move the Detect Hotspots component to this new object.

    It's then a case of controlling this new GameObject's position through animation. There are a couple of ways you can do this:

    1. If your character uses "Sprites Unity" as their Animation engine, you'll need to animate the position within their exising Idle/Walk etc animations. For example, Idle_L might give it a local position of (-1,0,0), and Idle_R (1,0,0).

    2. If they instead use "Sprites Unity Complex", you could also use a separate set of "Collider only" animations that are controlled in their own dedicated layer in the Animator Controller. These would then be played back using the same "Direction" parameter used to control the character's facing direction on the Base layer.

  • Separately: it looks like your character's sprite may be in the centre of the character's root. You should try to set the sprite "Pivot Point" values all to Bottom, so that the root is instead by the character's feet.

    This is because the NavMesh describes where the character's root object can move to.

  • Thank you Chris! As always!
    Your solution is very simple and logical, this make me think a lot of new things i can do with this principle...
    Thank you for noticing the root, now ive changed it to the bottom. And yes, is better for navmesh, colliders...

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.