Search Unity

adding walk to points

Discussion in 'Scripting' started by ghost123_1234, Oct 13, 2015.

  1. ghost123_1234

    ghost123_1234

    Joined:
    Jan 9, 2015
    Posts:
    88
    hello

    what i want to do is something like this:
    That you have an arrow that points toward youre point that you need to walk to:


    And then when you have it in youre view i want to do something like this:


    Its not necceserly needed to see how far you are away but it would be nice

    hope someone can help me
     
  2. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    What do you want? A complete script because those kind of requests don't go down well here. This isn't a free script forum its a scripting help forum.

    If you want advice on how to do this then:

    You need to workout where the destination is in relation to the cameras direction. Dot products are going to help you here.

    Once you have worked out if the camera is facing it you have a choice. Do you want the red square to enclose the entire object? If that is the case you will have to scale it based on the object bounding area. This could get quite complicated. If the red square is the same size regardless don't worry.

    Now if you determined that the object isn't in the viewport (using our nifty dot product or even a function on the camera possibly but I havent looked) then it will also have told you what side it was on. You just need to position it on the correct side of the screen.

    The distance display is nice and easy vector maths: (cameraposition + targetpostion).magnitude. Unity even has a nice method for you: Vector3.Distance.
     
  3. ghost123_1234

    ghost123_1234

    Joined:
    Jan 9, 2015
    Posts:
    88
    i dont want the red square i just want the dot to be seen on my camera
     
  4. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Ok advice updated:

    If you want advice on how to do this then:

    You need to workout where the destination is in relation to the cameras direction. Dot products are going to help you here.

    Once you determine it is on the screen convert that world point to a screen point and draw you square there.

    But if you determined that the object isn't in the viewport (using our nifty dot product or even a function on the camera possibly but I havent looked) then it will also have told you what side it was on. You just need to position the square on the correct side of the screen.

    The distance display is nice and easy vector maths: (cameraposition + targetpostion).magnitude. Unity even has a nice method for you: Vector3.Distance.
     
  5. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Like Korno said it not make the script for you. its help with your script.

    You would need to do these things in my way even though theirs tons of ways to do this.
    make a point where the walk to point is
    make a coordinate script to tell location of human to the point
    then basically update the thing

    if blabla is at this area & if camera is facing at this angle show arrow thing and subtract or add distance away from point.

    Not best explainer but hopefully you get what Im saying