Friday, December 16, 2016

Making Dialog Appear in Unity, Game Dev

I followed this tutorial for melee combat: Then just adjusted it for dialog. Basically using the same code to initiate dialoge instead of damage. Adjusting the MaxDistance to something farther away. And changing Fire1, to Fire2. Script for reciever:
function thingCast() {

Script for Sender:

                var hitt : RaycastHit;

                if(Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hitt))
                Distance = hitt.distance;
                if(Distance > MaxDistance){
                hitt.transform.SendMessage("thingCast", SendMessageOptions.DontRequireReceiver);

Assign the actual Canvas object to canvasObject in the inspector.

No comments: