I'm trying to animate a face using Anima2D for rigging.
Anima2D generates Sprite meshes for sprites that would be rigged and animated.
My problem is that I need to hide the tongue and teeth inside the mouth, and for that I was using sprite masks which are static and don't deform.
Is there a way to use sprite meshes as sprite masks? Or is there any other solution that I can use?
The image is an example of what's happening when I move the mouth (which uses sprite mesh). As the sprite mask (marked in orange) don't deform, the teeth and tongue bypass the mouth.
PS: I've found about stencils, but I don't think they would work since I need to hide sprites inside sprite mesh (not normal sprites).
In general, you would just need to change your "mask interaction" setting on the SpriteRenderer component on your tongue and teeth gameobjects and play around with the "Order in Layer" or "Sorting Layer" on these objects as well. Here's a quick example of what I quickly put together. Note the highlighted area:
Related
I have a procedurally generated dungeon BSP on a Tilemap Grid. a TileMap collider has been added to it.
I planned to do it simply, since my TileMap contain a SpriteRenderer, I add the color 0,0,0 to it like a black fog of war, and if I can't see it well or have already opened it i would repaint them with 0.5,0.5,0.5, and the area around the player would make 1, 1, 1. and that would be cool, BUT I only can get tiles from the map via VectorInt, or via an index and a copy of the array. Can I access each cell, somehow through a collider? To use something like Raycast or Overlap Colliders.
any collider or collision tells me about the TileMap map. Or do I still need to create each tile and attach them to a game object or Scriptable object? I'm confused, tell me, I reviewed many tutorials and questions on this issue and got confused
I don't completetely understand, but I'm pretty sure you want to add a tile during runtime? Or you at least want to change the tile so that it's black or has a fog of war?
First off, I found this link: How can i place a tile in a tilemap by script
However, that would be difficult, having to have some kind of array, or possibly 2d array, of all the tiles for when there shouldn't be a fog of war.
My suggestion is using a Sprite Mask , and setting the tilemap(the actual ground) to not interact with the mask, and having a big fog of war sprite, like a big black cloud that might follow the player around so that it doesn't need to be a massive sprite, and set it's sprite interaction to visible outside mask.
Finally, make a sprite mask that follows the player around, and therefore will remove the fog of war around the player.
Another thing is to make a big cloud sprite with a hole in the middle, and have it follow the player around. That way, there's a big fog of war, but there's a hole in the middle so the fog is not around the player.
I'm trying to make an application that has sprites going down the screen with numbers in them. The Text(Script) component only works for 3D objects. I've tried using Text Mesh and making that a child of the sprites but I need them to be instantiated as a Prefab. So when I load the sprite in as a prefab it loses it's relationship to the Text Mesh. Does anyone know of a solution that worked for them?
There are many ways to do it depending upon your requirement. I will show you two of the most basic.
1- Use 2D Sprite and TextMesh.
2- Use Canvas Image and Text Objects.
P.S First one, that is 2D Sprite can be Instantiated directly in the hierarchy but for 2nd(Canvas Image) you need to instantiate it inside the canvas obj means as a child of canvas object.
I have a power-up GameObject with a light component attached to it.
The sprite shows up fine, however, the halo effect does not work when the GameObject is placed over another sprite (eg a background wall).
I think its a problem with the material (as I have tried other things such as changing the culling mask, ordering layer, etc) - however, I don't know which properties to change in order to make the light visible.
I am using an area light.
I hope I saw correctly your game is 2D. If so, check out 2D Lights
I am having a problem with my unity canvas as my background is on top and covering my gameobjects. I have tried putting the canvas sorting order to -10000 and changing the canvas rendering mode to overlay/camera/worldspace, but none of them works..
This is how my game looks like right now:
as you can see the white image which is my background is covering my gameobjects..
Attached are my component values for my canvas:
my canvas
Attached are the values for my camera:
my camera
Attached are the component values for my gameobjects:
my hero gameobject
Have you tried setting your game objects z position to a negative value?
For 2D games in Unity, the more negative your Z value is, the "closer" it is to the camera. If you try setting your knight to something like -1, it should no longer be obscured by your background.
Also, make sure to set the camera for your canvas' render camera and you can set the sorting order back to whatever it was before. Just check the individual pieces attached to your canvas to make sure their Z positions aren't "in front" of the game objects.
The background for your game shouldn't be on the canvas, it should be a gameobject with a sprite renderer and need to be attached with a sprite(background image) with a resolution that will fit most mobile screens (assuming you build it for mobile phone, i personally prefer making it 1028X720)
if you still insist on putting it on the canvas then you could set the canvas render mode to world space and set the sorting layer to something less than default or sort order -1
I know it is old post but #user8502296's answer saved me so I wanted to contribute. I changed the Canvas->RenderMode->Screen Space-Camera then I added Render Canvas->Camera->Main Camera.
Canvas
sorry for my bad english. I'm from germany^^
My question:
Is it possible to transform an empty game object into a shape that Looks
like a Piece of cake? I have a round terrain and I want to "cut" it in
three pieces of cake, because I want to play different music in all three areas. I Need These pieces of cake as a box/mesh collider or something like this, so I can Play different Songs if the Player collides with the box/mesh collider.
Ideas anyone? Please help me. :)
Is it possible to build an object in Blender for example and use it
as an invisible box collider?
Create the shape in Blender. Create a MESH COLLIDER. Assign your piece of cake model to the MESH parameter of the MESH collider. Scale it. Position it. set it as trigger and VOILA!
This would be the mesh you create in blender (RED)
then,
void OnTriggerEnter(Collider other) {
//play song
}
The other answers have covered options of generating a mesh outside of Unity and using it to make a mesh collider trigger for your music changes.
Other options:
Native Unity collider option:
Use two native cube mesh colliders to create a sandwich of two thin colliders at the borders where the music needs to change. Do some OnTriggerEnter/OnTriggerExit scripting to make the music change correctly when the player crosses the borders.
Pure scripting option:
Use the player position relative to the "center of the cake" point to calculate when to change the music based on where the player is located.