- Home /
How to make flat object(Unity 2D)
I am working on a project to generate objects and letting be arranged out in 2D space to my choosing, I found a tutorial but the generated objects do not appear flat. I want them to appear flat and not have the shadow shown.
I have tried removing the rotation(rotationAmount) component of the code and it results with the Scene component appearing flat and how I want it but in the game scene it still has the shadow and looks as if some rotation was applied to it. here is the code. I am fairly new to unity dont know what else to change.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScreenPosition : MonoBehaviour {
public float distance = 10f;
public float distanceChange = 1f;
public float rotationAmount = 0f;
public float rotationDelta = 0.0f;
float posX = -1f;
float posY = -1f;
float posZ = -1f;
private void Update()
{
if (Input.GetMouseButtonDown(0) || Input.GetMouseButton(1))
{
distance += distanceChange;
Vector3 clickPosition = new Vector3(posX, posY, posZ);
clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0f, 0f, distance));
Debug.Log(clickPosition);
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = clickPosition;
rotationAmount += rotationDelta;
cube.transform.Rotate(new Vector3(rotationAmount, 0f, 0f));
}
}
}
Answer by CardboardComputers · Aug 13, 2020 at 04:09 AM
Change your camera from perspective to orthographic, i.e. set orthographic to true. You should also consider using 2D objects, such as squares or sprites, rather than 3D objects like cubes.
Your answer
Follow this Question
Related Questions
Arm Rotation toward Cursor Script Help 1 Answer
Rotating a 2d object 1 Answer
Simultaneously translating and rotating 2D sprite? 1 Answer
2D rotation around a object 4 Answers