- Home /
 
problems with using a camera as a texture
I'm trying to prototype out an idea that uses a flattened cube as the characters in my game. Above ground (what the player will see) is a flattened cube with the texture being the view of an Orthographic camera which is attached to a 3d modeled character (currently a free asset from the store as a stand-in). This gives the cube that the player sees the impression of a flat paper character but the character will rotate in full 3d rotation instead of having to use a billion sprites for each character to show each degree of rotation for every animation that the player character could possibly do at each degree of rotation.


The cube is fixed to always face the camera and the camera is fixed to the cube so it never rotates either. It's similar, I suppose, to paper Mario, if Mario was drawn to show him facing 360 degrees instead of maybe 8 positions.
The problem I'm running into is the texture is showing artifacts around the character on the cube texture even though I have the camera culling out everything except the 3d model. Also, I may just not know how to make things play the correct animation (walking) when I have the cube move. I'd like for the cube to show the 3d model walking when the cube moves.
I have a script attached to the cube for the cube to move anywhere the player clicks on the ground.
Here's the script:
 #pragma strict
 //MoveToClickPoint.js
 var agent: NavMeshAgent;
 var speed : float;
 
 //var playerPOS : Vector3;
 //var relCameraPos : Vector3;
 //var player : Transform;
 
 
 
 function movePlayer() {
     if (Input.GetMouseButton(0)) {
         var hit: RaycastHit;
         
         if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit, 2000)) {
             agent.destination = hit.point;
         } if (Input.GetMouseButtonUp){
         
         }
     }
 }
 
 
 
 
 function Start() {
     agent = GetComponent.<NavMeshAgent>();
     
 }
 
 
 function Update() {
     transform.eulerAngles.y = 0;
     movePlayer();
     //getTouchPosition();
 }
 
               Does anyone know why the texture is showing artifacts in the background of the character, or have any suggestions on how to improve on this idea?
Thank you all!
Answer by FortisVenaliter · Aug 19, 2015 at 08:14 PM
Because your clear flags for that camera are set to depth only. So, when the view changes, it won't clear out the color buffer. What you probably want is to have it clear to transparent black (but you can't use full transparency), so I'd suggest having it clear to a solid color, that color being (0,0,0,1/255f)
Your answer