I am working on a simple board game. I have the game working, player pieces moving around a board,etc. What i wanted to do was add dice (a 3d gameobject) to the canvas that i could lock in the top-right corner so a player could click on the dice which then spins and stops on a number. i have the dice working in my scene view but i can’t figure out how to lock it in on the screen. I have several cameras that move around as players move so i can’t child it to a camera.
So, any suggestions? Best i can think of is to have several dice, one attached to each camera, but that doesn’t seem right. It seems like i should be able to put it in the top right corner of a screen overlay canvas, but it doesn’t show up.
I’m sure this is something really simple, thanks for the help.
James
3d objects don’t work in overlay. You’ll have to use screen space camera canvas. You could attach it to the canvas and have the canvas switch cameras, but I don’t know how often you would need to do that. There is probably a better way.
This part is a bit unclear to me – what’s stopping you from attaching a camera to a die? And/or zoom in/out or play with the FOV to have all dice in view? Then either use the camera viewport settings to render to a portion of a screen, or use a RenderTexture which you can then use in the screen overlay as a RawImage?
1 Like
I could do the zoom in/out thing, its just not what i initially wanted to do, but may be what i go with. Will have to look into camera viewport settings and figure out how to render to a portion of the screen. Will also look into RenderTexture as RawImage. Not sure what this is but if its just an image i dont think the spinning dice animation would work. These 2 things i know nothing about. Any sample code/pseudocode you may have or suggestions for a decent tutorial would be greatly appreciated.if not im sure i can figure it out, just takes me a while
Im a total noob at this point, this is only the 3rd game i have worked on from scratch, so trying to learn as i go.
Thanks for the suggestion guys.
James
There’s a nice RenderTexture tutorial video here:
Bonus: The camera is attached to a cube (can think of it as a die), so it might come pretty close to what you’re looking for?