The game is a 2D, direct-controlled game (using WASD) My player and NPCs all use rigidbody 2D components and circle colliders for their feet, so that they can walk up and down slopes (and follow the player at times) - The NPCs are not static
But when I walk across the NPCs, my player's circle colliders collide with theirs, pushing them along as I make the player walk. How do I go past them, as if they were behind the player? Thanks!
Comments
In that case, placing the Player object on a separate Layer and modifying Unity's Physics settings to have it ignore your NPC root layer should do the trick. The NPC Hotspot will need to be on Default, but that shouldn't bee the root object anyway, so you should be safe to change the root layer to a new "NPC" layer.
You may want to tweak the characters so that those yellow circles appear at the character's feet, however, as that is where AC considers their positions to be.
Jumping is not possible in the AC controller because 2D is expected to behave differently to the way you've managed it - but a simple call of Rigidbody2D.AddForce in a custom script could concievable add this on top.
Hello, back to this post after 1+ year. As @ChrisIceBox said(in the last comment), this method is giving me issues with saving and loading.
I've set up the characters correctly (root object on a custom layer, child object on default layer) Asking AC to "Auto add save components to Game objects" adds "Remember NPC" to all my NPCs root object. This changes the root objects layer from "NPC" (a custom layer I've set up to avoid collision with my player, as suggested earlier in this thread) to "Default" only during runtime and the player and different NPCs begin pushing each other on contact again.
Any workaround? Thanks!
Let's see your NPC's full root hierarchy in the Inspector. What are his other components, and what are your AC/Unity versions?
Ac version -v 1.65.2 , Unity - 2017.2.0f3
Here are the images
Thanks. Already scheduled to be in v1.66 is a fix to prevent the RememberNPC component from affecting the object's layer unless it has a Hotspot component but no RememberHotspot component as well. PM me if you'd like to be included in beta-testing.
Sure, will send a PM. Thanks!
@ChrisIceBox
Hi. Is the above fixed? I need an NPC with a Hotspot and RememberHotspot component, along with a RememberNPC component. This changes the NPC's layer on runtime to ignore raycast, causing collision problems. Any workaround?
Perhaps my phrasing could have been more clear. A RememberHotspot component will set the object's layer to either Default ("On") or Ignore Raycast ("Off") depending on the Hotspot state on start Inspector value.
If you need the root object to be unaffected, just move the Hotspot / Remember Hotspot components to a child object, and give it a Trigger collider. Unless this is also on the sprite-child, be sure to also uncheck Turn root object in 3D? in the NPC Inspector to prevent the Hotspot from turning on the z-axis.