- Home /
[2d] Sprite drawing offset from real position
Hello,
Noob question: I want my object to be able to overlap with world objects, like in this image:
In this example black rectangle is a wall, red circle is game object sprite and green circle is actual object position with collision circle. Question is - on collision with wall, how to add offset to sprite without changing actual position of the object? If I change GameObject position after collision it will fall through walls.
Answer by TurboHermit · Feb 27, 2014 at 04:26 PM
There's a couple of ways to do this. Are you using the new 2D stuff unity offers? In that case you should look into Depth Layers. If you're using 3D I suggest the solution I usually use, make a child object with the art and move that position. That way the collision of the parent remains intact but the art will be drawn over it.
I'm sorry but can You be more specific? I'm using 2D stuff (as stated in description). Do You mean Sorting Layers? If so, I believe You misunderstood the problem, this is not a depth/sorting problem.
$$anonymous$$ost likely so. I think I might have a solution though. You can make the sprite art a different object that uses the exact same movement input or even let it follow the collision object, but once it collides it goes its own way according to a bool or something.
Your answer
Follow this Question
Related Questions
Is it fine to use a separate quad for collision on a sprite? 1 Answer
Collision detection not working properly with 2D sprites 1 Answer
I drew a 2d Maze. How to collide with walls. 1 Answer
Stop moving when colliding. 2D 1 Answer
Collider act at position offset from what is displayed,Collider position is offset from it's object? 0 Answers