Jump to content

Search the Community

Showing results for tags 'callision'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Proyectos
    • Offtopic
    • Unity Feeds
    • Website
    • Youtube
  • Mesa de ayuda
    • Unity
    • Arte
    • Builds & Dispositivos
    • Otras Especialidades
  • Aportes de la Comunidad
    • Recursos
    • Eventos
  • Bolsa de trabajo & Colaboraciones
    • Ofertas y Demandas
  • Post Antiguos
    • General (Antiguo)

Blogs

There are no results to display.

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Especialidad

Found 1 result

  1. Estoy intentando modificar un sistema de notas de un tutorial para adaptarlo a tercera persona, lo que quiero hacer es sustituir el raycast solo cuando third este activo, por colision al tag "Note", o la funcion OnTriggerStay o OnCollisionStay... pero si con js me lio, con c# ya me resulta jodidisimo... Bueno esto es lo que tengo puesto en el player, he probado a aumentar el raycast en third (sin exito) y no se como sustituir el raycast por alguna de las funciones que he comentado. El script este seria el del player para ambos estados (fist y third), el de la nota ya lo tengo resuelto. La funcion CheckForNote esta dividida en 2 partes: en la parte if first ActiveSelf... no hay problema y se ve la nota al acercarte y pulsar el boton en la parte if third ActiveSelf... es donde quiero sustituir el raycast por colision o por ontriggerenter, pero no se como hacerlo. using UnityEngine; using System.Collections; public class PickupNote : MonoBehaviour { //Maximum Distance you Can Pick Up A Book public float maxDistance = 1.5F; public GameObject first; public GameObject third; //Your Custom GUI Skin with the Margins, Padding, Align, And Texture all up to you private GUISkin mySkin; //Are we currently reading a note? private bool readingNote = false; //The text of the note we last read private string noteText; void Start () { //Start the input check loop StartCoroutine ( CheckForInput () ); } private IEnumerator CheckForInput () { //Keep Updating while (true) { //If the 'E' was pressed and not reading a note check for a note, else stop reading if (Input.GetButtonDown("accion")) { if (!readingNote) CheckForNote (); else readingNote = false; } //Wait One Frame Before Continuing Loop yield return null; } } private void CheckForNote () { if (first.activeSelf == true) { //A ray from the center of the screen maxDistance = 2.3f; Ray ray = Camera.main.ViewportPointToRay (new Vector3 (0.5F, 0.5F, 0)); RaycastHit data; //Did we hit something? if (Physics.Raycast (ray, out data, maxDistance)) { //Was the object we hit a note? if (data.transform.name == "Note") { //Get text of note, destroy the note, and set reading to true noteText = data.transform.GetComponent <Note> ().Text; mySkin = data.transform.GetComponent <Note> ().mycustomSkin; readingNote = true; } } } //HASTA AQUI TODO BIEN, ESTA ES LA PARTE DONDE EL RAYCAST PODRIA SUSTITUIRLO POR ONTRIGGERSTAY?¿QUE FUNCION SERIA MAS ADECUADA??? if (third.activeSelf == true) { maxDistance = 5000f; //pense que aumentando la distancia leeria la nota Ray ray = Camera.main.ViewportPointToRay (new Vector3 (0.5F, 0.5F, 0)); RaycastHit data; if (Physics.Raycast (ray, out data, maxDistance)) { if (data.transform.name == "Note") { noteText = data.transform.GetComponent <Note> ().Text; mySkin = data.transform.GetComponent <Note> ().mycustomSkin; readingNote = true; } } } } // A PARTIR DE AQUI TODO BIEN void OnGUI () { if (mySkin) GUI.skin = mySkin; //Are we reading a note? If so draw it. if (readingNote) { //Draw the note on screen, Set And Change the GUI Style To Make the Text Appear The Way you Like (Even on an image background like paper) GUI.Box (new Rect (Screen.width / 4F, Screen.height / 16F, Screen.width / 2F, Screen.height * 0.75F), noteText); } } }
UnitySpain © Todos los derechos reservados 2020
×
×
  • Create New...