Forum rules - please read before posting.

Hotspot Detector - Four Directions Compatibility

First of all, great to be back! Cranked out my latest game in RPG Maker again to get it all situated in time for festival submissions and the like, but now I'm back into moving it over to Unity and Adventure Creator.

So, here's my problem - I'm in 2D, working with overhead sprites (JRPG style) that only move in four directions. Rather than a hotspot detector that sits directly below the character at all times, though, I want it to be a bit in front of whatever direction the character is *facing*. 

I get the sense that it works this way by default in 3D, but it doesn't seem to be the case in 2D. Let me know if what I'm looking for is not clear - what I'm saying is that I don't want hotspots to trigger unless the character is facing towards it, so I want to use a narrow hotspot detector that sticks out the direction they are facing. So when facing left, offset to the left. When facing right, offset to the right, Up when up, down when down...

For reference, in my last game I just made the hotspot detector a full circle around the player and set the hotspot detection to the nearest only. It worked not too bad, and players would pretty much intuitively face towards the hotspot object anyways, but it'd be perfect for it to work like this instead.

Please let me know if anyone has encountered and overcome this...!  Thanks!

Comments

  • Welcome back, @willoneill!

    The way AC handles 2D characters is to rotate them in 3D space, but keep their "sprite childs" facing the camera at all times by counter-rotating them.  This means that you'll need to have your Hotspot Detector be a child of your sprite in order to have it correctly orientated.

    You could try animating the position of your Hotspot Detector as part of your player character's animations.  Placing it to their left for the left-facing idle/walk/run animations, for example.
  • Hey Chris,

    Thanks! I've moved my Hotspot Detector to be a child object of the sprite to start with. Animating the position of it seems like an idea that should work, but I'm not sure how to go about doing it - can you point me in the right direction? Is this something I would do in the 'Animation' tab or the 'Animator' one? Or would this be a part of some sort of ActionList in AC?

    I've looked through each but don't see a place or way that allows me to 'Transform Object' or something like that...
  • edited December 2016
    Do it in the animation tab, it should be exactly as animating any other non skinned object. In fact the best would be to just alter the animations you already have for your character to include the hotspot detector position. That way you won't have to modify anything in your animator. If you have any doubts, take a look at the Unity tutorials on animation, or check this old but still useful live session: Animate anything with mecanim.
  • In the Animation window.  You should already have animations (presumably sprite-changing) for your character standing/walking etc in different directions, but Unity can animate other properties as well in the same animations.  While recording an animation, change the object's position.  See Unity's own set of tutorials for more on how to use the Animation window.
  • Excellent, fellas - I was fairly sure this was a Unity thing and so didn't want to bug anybody beyond asking for a push along the best trajectory. I'm sure I can figure it out from here, and I'll report back if this does indeed work...!
  • Great news: It worked!

    To anyone else trying to do this who finds this thread, one key thing to remember, though I don't know if it will happen to everyone: When I added the curve that transformed the position of the Hotspot Detector, by default it made that transition happen gradually over each frame of the animation. 

    Of course, you don't want that - so make sure the full transform happens on the first frame, and delete the X and Y transform keyframes at the end of the animation!

    If you test this and it looks like your hotspot highlight or label is fading in and out like a busted light, this is probably what is happening... :)
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.