Unity Community


Results 1 to 2 of 2

Thread: Need litle help


  1. Location
    UKRAINE
    Posts
    11

    Need litle help

    THIS WORK
    var tochka =Vector3(0,0.03,0);

    if (transform.position==tochka){
    audio.Play();}
    else {audio.Stop();}
    BUT I NEED THIS
    if (transform.position>=tochka){

    HOW TO DO IT?
    Last edited by korbljud; 04-13-2012 at 05:09 PM.


  2. Posts
    379
    Quote Originally Posted by korbljud View Post
    THIS WORK
    var tochka =Vector3(0,0.03,0);

    if (transform.position==tochka){
    audio.Play();}
    else {audio.Stop();}
    BUT I NEED THIS
    if (transform.position>=tochka){

    HOW TO DO IT?
    Well, first off, the reason that the existing line works is because it makes sense to check if two vectors are equal. However, it doesn't make complete sense to check it a vector is greater than or equal to another vector. What exactly are you trying to test for here? Are you trying to play a sound when this object is close to "tochka"?

    If so, you need to get the distance between the vectors and check that distance. Hopefully that helps some!
    Andy - Altered Reality
    http://www.alteredr.com -- WE ACCEPT PAYPAL!

    ===========OUR UNITY MIDDLEWARE===========
    Sage: Anim Graph Editor -- Animation State Machine and Blend Graph Editor
    Visualizer Studio -- Game Music Visualization/Reaction
    CuRSe: Collision Reaction System -- Physics Object Collision Reaction System
    Search Grid -- Quick Spatial Object Searches
    Locator HUD -- Directional Indicator GUI
    Time Machine -- Undo-Redo Scripts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •