Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Apr 08, 2016 at 02:40 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by NoName115 · Mar 23, 2014 at 03:30 PM · 2djavascripttransformposition

If two Vector2 are same

I need to get True/False, if first Vector2 is equal to second Vector2.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gruffy · Mar 23, 2014 at 05:13 PM 0
Share

fi() { vect1.position >= vect2.position }

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Gruffy · Mar 23, 2014 at 05:29 PM

Hey bud try this out.

You need a gameobject in your scene that will move to another gameobject, so have two game objects that your camera can see in the scene. The add this script to one of them and then add the other gameobject`s vector coords in the public slot in the inspector showing x y positions. Press start and you should see the first gameobject (with this script atttached to it) move along to the other one you gave vector coords for and when it arrives itll stop (itll probably happen quite fast unless you put some distance between the two gameobjects) Before you start the Play button in the eidtor, get your console window up and see that you have a debug happeneing saying "false" over and over again. when it has reached the vector coords specified in your script for vect2, it will say "true" and a text statement afterwards. Hope this helps dude. Gruffy

 using UnityEngine;
 using System.Collections.Generic;
 public class MyClass : MonoBehaviour
 {
 public bool myBool = false;
 private Transform vect1; //set in inspector
 public Transform vect2; // set in inspector, this is 
 void Start()
 {
 vect1 = transform.position;
 }
 void Update()
 {
 //move this transform towards the vect2 position you gave in inspector panel for this script
 transform.Translate(vect2 * Time.deltaTime);
 //if vect 1 not same as vect2
 if(vect1.position != vect2.position ) 
 {
 myBool = false;
 Debug.Log(myBool);
 
 }
 else
 {
 myBool = true;
 Debug.Log(myBool + "You have reached your destination");
 }
 }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NoName115 · May 06, 2014 at 05:24 PM 0
Share

Thank you very much, you really helped me thanks.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation changes constantly reset themselves. 1 Answer

iscometric grid panning 0 Answers

Get angle between a position and facing direction 0 Answers

Trying to Generate Different Random Values for Position of Game Object Instances [C#] 1 Answer

How to move a 2D object toward the position it is pointing to? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges