Greetings,
New Unity User here. (and in general to 3D Game Development)
After a couple of experimentation with Unity. (mainly involving player interactions with objects, inventory management, etc) I started to dwell in doing a bit more advanced tests.
Recently, I started experimenting with Random Dungeon Generation using predefined Templates which I will create.
In short, there will be a GameObject on the template, which rotation and direction will be used to determine where the next template(s) can be applied to, towards which direction, until no free ‘entrance’ is available. I know there are its own inherit issues, but I will try to find solutions for them as well
So far, I’ve gotten stuck with Gizmo creation which would make it easier to create such templates.
I might be heading to the wrong direction,
But after looking through the Gizmo documentation, I did not find any method to actually draw the gizmo with a set rotation as a plane, for example. So I went ahead and wrote a script which will keep draw a line between 4 points in an area of set-values (in this example, 2x4 units).
The issue is The shape of the door way is not consistent at any angle except for 90 degrees in the X axis. Every other angle will absolutely destroy the shape, but are constraint to a Spherical Influence.
Apologies for my Math, but unforgivably, it is not my strong suite as I’m used to the engines calculating it for me; So I do need some help with this.
Here is the code I have written in C# (a language I’m new to as well, but trying to learn with basis in Java)
using UnityEditor;
using UnityEngine;
using System.Collections;
public class RoomEntityGizmo {
[DrawGizmo (GizmoType.NotSelected | GizmoType.Pickable)]
static void RenderLightGizmo (GameObject obj, GizmoType gizmoType) {
RoomEntry script = (RoomEntry) obj.GetComponent("RoomEntry");
if(script != null)
{
Vector3 position = obj.transform.position;
Quaternion rotation = obj.transform.rotation;
Vector3 forward = obj.transform.forward;
float modifier = 0.5f; // Will Later on increase this if Gizmo is selected.
Gizmos.color = Color.blue * modifier;
Vector3 difference = new Vector3 (script.sizeX,0,script.sizeY);
difference = rotation * difference;
Gizmos.color = Color.yellow * modifier;
Gizmos.DrawLine (
new Vector3( position.x - difference.x, position.y + difference.y, position.z + difference.z ),
new Vector3( position.x + difference.x, position.y + difference.y, position.z + difference.z)
);
Gizmos.DrawLine (
new Vector3(position.x + difference.x, position.y + difference.y, position.z + difference.z),
new Vector3(position.x + difference.x,position.y - difference.y,position.z - difference.z)
);
Gizmos.DrawLine (
new Vector3(position.x + difference.x,position.y - difference.y, position.z - difference.z) ,
new Vector3(position.x - difference.x, position.y - difference.y, position.z - difference.z)
) ;
Gizmos.DrawLine (
new Vector3(position.x - difference.x, position.y - difference.y, position.z - difference.z),
new Vector3(position.x - difference.x, position.y + difference.y, position.z + difference.z)
);
}
}
}
There is a mistake defiantly somewhere here.