Forum rules - please read before posting.

2D Questions and issues

edited July 2014 in Technical Q&A
Trying to use AC to build a 2D adventure game and running into a few hitches...

- Is object highlighting supported in 2D? If not, is it something that conceivably could be added?

- Is holding objects possible in 2D? Obviously it wouldn't work the same as how it does w/ a 3D model, but seems like it'd be very feasible to incorporate the same functionality using empty child gameobjects(?)

- Does Hotspot Detection by player vicinity not work in 2D? I went through the tutorial but it doesn't seem to be functioning - I tried both with the sphere collider attached to the empty object, as well as with a circle collider in case the steps were slightly different for 2D but neither worked. My assumption was that this feature would make the hotspot name appear as you got close to it, so if this isn't how it works, that may be why it doesn't seem to be working(?)


  • - Scratch the highlighting question - last time I tried using it (different version) it didn't work, but just tried now and it works perfectly!

    - New question/issue with NavMesh2D... The tutorial says that the fewer the points the better, but I'm running into a problem that seems to be caused by the reduced points. I have a simple room layout requiring only a basic 4-point polygon collider, but when I click below the player, half the time he'll walk off to the left/right before then moving diagonally to where I clicked - almost like he's tracing the vertices of the two triangles making up the 4-point collider. When I arbitrarily add half a dozen points to the square, the issue goes away. I don't know how the logic of the polygon collider pathfinding works, so this may be consistent - is there such thing as too few points on your navmesh?
  • It's not currently possible to hold objects in 2D, but it's a good feature to add.  Are your characters animated with separate sprites for each limb?  I only imagine it working properly if that's the case.

    Same for Hotspot Detection - it's a bit of an oversight on my part that it doesn't currently work in 2D.  I'll have it added in 1.37.

    There shouldn't be a minimum required number of NavMesh points.  The minimum I've tested with, however, is 5 - the default PolygonCollider shape works fine.  Are there any "holes" defined?
  • edited July 2014
    There was one hole, but removing it didn't change anything. The issue seems to have more to do with the space between points rather than the number of points in the polygon. For example, I made a large rectangular map from 4 points, then on the left side I added a bunch more points but kept the right side simple - when I tested it, the issue only appeared on the right side, whereas the left side with more points navigated smoothly. Below is a video showing the issue - in this instance he only navigates oddly when pathfinding down, but that's just a coincidence - I've seen it happen both ways.

    You're right about the object holding - much more complicated than I anticipated :(
  • I've thought about this one because I want to show a character using specific objects in order for it to make more sense with how it affects the scene objects.

    Am I right in thinking it would be sufficient to have an extra animation frame-set/sequence where the character has the object in their hand in order to complete an action? ie going from standing there to holding a match, striking it and lighting a candle.

    Or is there not a way to use a custom animation "in the action" I guess its effectively an in-line cut scene right?
  • @DieHappyGames: I can't see the actual NavMesh in your video.  Could it be that you're actually clicking beneath the NavMesh?  The problem may go if you lower it enough.


    @Xidore: I'm not sure what you mean by "in the action", but you can both play custom actions and change the "standard" ones (walk / idle etc) in-game, though the exact method depends on what engine you've set in your Character inspector.

  • That does appear to the the origin of the issue - it only occurs when clicking a spot outside of the navmesh. Is there a way of fixing this? I don't know about 3D, but this is something that would crop up constantly in 2D adventures: the user rarely clicks on the floor as their intended destination, but rather on a wall, object, etc, meaning for the character to walk to the point on the floor nearest whatever they clicked on.
  • edited July 2014
    Is there a trick to making object highlighting work in 2D? I know that it's possible because the first interactable I setup was working perfectly (to my surprise, since it hadn't when I tried a couple months ago) but somewhere in the last two days it broke and isn't working either for new objects or the old one that worked before :( As far as I can tell I haven't changed anything that should have affect it, and I'm setting up new ones just the same as the original that worked perfectly...

    EDIT: From what I understood, reading through the highlight script, it affects the color property of the renderer. When I set the color of my highlightable object to grey, I could then see a highlighting effect, where the object went from being dark to appearing fully lit on mouseover, but of course the idea is for it to be fully lit to begin with and then light up on mouseover, which is how it was working originally but I still can't figure out why it stopped / doesn't work with new objects... Any light you can shed on this issue would be appreciated (*pun)
  • Not having changed how the highlighting script worked, I'm confused as to why you saw a change.  Could it be down to an update in Unity itself?
  • The only thing I can think of that might have done it is that somewhere in between when it worked and when it stopped, I realized that my project settings were on 3D when they should be 2D, so I corrected that. Sometime after that was when I noticed the highlight wasn't working, but I tried setting the project back to 3D as part of my troubleshooting to get it working again to no avail.

    Chris, am I correct in assuming that object highlighting should work in 2D with sprites without any special steps? Just attach the Highlight component to the sprite in question and link it to the given hotspot in the "object to highlight" field?
  • Unless I'm misunderstanding how it works, the position offset for menu items (which works perfectly for the "follow cursor" option) doesn't seem to work with "on hotspot". I'm trying to adjust the hotspot menu so that object names appear above the hotspot, but no matter what I set for the x/y offset values, the name always appears right in the middle of the hotspot...(?)
  • 2D highlighting: Be sure to give your highlightable sprites the Sprites/Diffuse shader, rather than the Sprites/Default one.  2D highlighting only works for that shader type - you will have to light such objects in your scene as you would 3D.

    OnHotspot menu items: That is a bug, thanks for the alert.  Will fix for the next update.

  • edited July 2014
    I haven't been able to identify what caused the break, but I don't think that's the issue. I started a brand new project and the highlight is working again, with the default sprite shader and no need for lights in the scene. I also started by loading up your 2D demo and adding highlight to the interactables in there (which also use the Sprites-Default shader) and it works there too. Will keep my fingers crossed that it stays working this time.

    EDIT: The weird gets weirder. I just opened my old project (in which highlighting was broken) to check something, then when I went back to my new project (didn't change/save anything) highlighting is now broken in it as well. Quit Unity without saving, relaunched and it's still broken in the new project. Have no idea how that would happen but it's starting to look like a bug w/ the unity engine :(
    EDIT2: Scratch that, it had nothing to do with having opened a project in which the highlighting wasn't working, but rather closing the project to begin with. Have it narrowed down to repeatables and am inclined to think it's a bug w/ unity, but Chris, maybe you know better. If you create a new project, import AC and load the 2D demo, you can add the highlight component to an object (ie. park bench) and tie it to that object's hotspot. Play the game and you'll see that the bench highlights perfectly on mouseover. Save, quit Unity and then relaunch. Play the game again and you'll see the highlight no longer works.
  • Not sure quite why this is happening but Chrome thinks your demo zip file is dangerous:

    " is malicious and Chrome has blocked it.
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.