Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Finger Touch instead of First Person Character.

Discussion in 'Scripting' started by Manolocs, Jul 27, 2014.

  1. Manolocs

    Manolocs

    Joined:
    Oct 27, 2013
    Posts:
    5
    Hi, probably is too easy but.....
    This Script is working well, got it from Boris Media, it shows a text when the character enter in the box collider, what I want is instead of the first person enters in the box collider, the user touch the box collider so the text appears.
    Thanks in advance.

    Code (JavaScript):
    1.  
    2. #pragma strict
    3.  
    4. var note : GameObject;
    5.  
    6. function Start () {
    7. note.SetActive (false);
    8. }
    9.  
    10. function OnTriggerEnter () {
    11. note.SetActive (true);
    12. }
    13.  
    14. function OnTriggerExit () {
    15. note.SetActive (false);
    16. }
    17.  
     
    Last edited: Jul 28, 2014
  2. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Do you mean touch in terms of an Mobile based game? Or just literally touch the cube in game?
    I'll assume you mean just touch the cube in game.
    If you create a sphere collider on the cube, make it "is trigger", and make your Box Collider "not trigger", it should solve your problem. Or else, you could always have a secondary cube inside of that :)
    I had a perfect way of fixing this before, but I cant remember right now :/
    If I remember, I'll add it on here.
     
    Manolocs likes this.
  3. Manolocs

    Manolocs

    Joined:
    Oct 27, 2013
    Posts:
    5
    @Sykoo, I have a 3D model running in the iPad, so this model has a script to zoom and rotate, I need to identify some parts of this model at the user touches, I would like the touch trigger a information window explaining about that part of the model. If you know a tutorial please send to me, I really appreciate any help in this matter. :)
     
  4. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    EDIT: Note that Input.GetMouseButtonDown(0)) is Left click on your mouse but also can work as touch of a finger on smart phones, so don't worry about setting up the 'super advanced touch settings' :)

    Create variables of GameObjects and assign the body parts to those variables from Inspector window.
    For example:
    And then set a simple Text variable:
    Make it empy, as we're going to edit it soon in the functions.

    And then set some booleans like:
    Then after that, you could try something like this under function OnTriggerEnter()
    After doing this for every single bodypart, go ahead and:
    And to make the text visible on screen:
    Note: You can play around with the resoltuion (20,20,100,20), but just to mention that it can also be off-screen, so if you edit it too much and its not visible anymore, just undo the last step you did and it will be back on screen :)
    Hope this helps ^^
    Let me know if you need anything more :)