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 /
avatar image
0
Question by nash · Nov 10, 2011 at 06:04 PM · c#transforms

transform Vector3 help!

I need help how to do this logic on code

Vector3 myPosition;

myPosition = "Vector3 of this object"?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by FLASHDENMARK · Nov 10, 2011 at 07:03 PM

 Vector3 myPosition;
 
 myPosition = transform.position;

You can call and use an objects position, rotation, scale(and much more) by referring the transform of an object.

Comment
Add comment · 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
0

Answer by Wentzel · Nov 10, 2011 at 06:14 PM

using UnityEngine;

using System.Collections;

public class example : MonoBehaviour {

public Vector3 p;

void Awake() {

p[0] = 5; }

}

Access the x, y, z components using [0], [1], [2] respectively.

I use javaScript but this should work fine.

Comment
Add comment · Show 6 · 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 FLASHDENMARK · Nov 10, 2011 at 06:59 PM 2
Share

Why so complicated? This is way beyond the understanding of a rookie.

avatar image Wentzel · Nov 10, 2011 at 07:08 PM 0
Share

You are propably reading it wrong, First Vector3 is Assigned to the Variable p.

So p can be used as the base for the Coordinate values such as if you want the Y value moved p[1] = 2.

$$anonymous$$ore info http://unity3d.com/support/documentation/ScriptReference/Vector3.Index_operator.html

avatar image FLASHDENMARK · Nov 10, 2011 at 07:16 PM 0
Share

Your logic is right, but it is way to complicated. Since we are dealing with a Vector3 ins$$anonymous$$d of using arrays(?) access the x, y or z value(s) of the transform. If you want the y value changed use the y value of the transform ins$$anonymous$$d of using p[1] = 2;

avatar image Wentzel · Nov 12, 2011 at 12:33 PM 0
Share

He was just asking for help, he didn't say it must not be complicating.

Really it doesn't look like he is willing to learn, Good luck to nowhere.

avatar image FLASHDENMARK · Nov 12, 2011 at 01:10 PM 0
Share

This was not an attempt to offend you. If I did, I am sorry. I was just stating that this could be done more simply. If this works out for you please by all means continue to use this method.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Distribute terrain in zones 3 Answers

Why is not assigning new value ? 1 Answer

Multiple Cars not working 1 Answer

[Solved] Problem Finding Closest GameObject to Cursor Point 1 Answer


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