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 ina · Jan 14, 2011 at 07:20 AM · rotationpositionstringtypecasting

Converting www.text or string to rotation or position

How do you convert a string to a rotation (quat) or position (vector3) value?

Format: var strQ:String = "(0,0,0,1)"; or var strV:String="(1,3,5)"; ... how do you conver the strQ to a quaternion and the strV to a vector?

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
1

Answer by Edwige · Feb 01, 2011 at 05:38 PM

This is not a real answer, but it may helps anyway.

I had the same issue : I stored character position (Vector3) in my database, and I had hard time retrieving it. Finally, I find it easier to store float in my database for each value.

posperso is a Vector3 where is stored my position. For the form, I send it like that :

var posx : float = posperso.x;
var posy : float = posperso.y;
var posz : float = posperso.z;
var posxstr = posx.ToString();
var posystr = posy.ToString();
var poszstr = posz.ToString();

So, in my database, I have 3 fields instead of 1.

When retrieving these data, in my php code, I have just put a blank between the values.

Then, back in Unity again :

var tab : Array = new Array();
tab = formText.Split(" " [0]);
var posx : float = float.Parse(tab[0]);
var posy : float = float.Parse(tab[1]);
var posz : float = float.Parse(tab[2]);
posPerso.x =posx;
posPerso.y =posy;
posPerso.z =posz;

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 Maarten · Jan 14, 2011 at 12:43 PM

It all depends on how the string is presented. So you need to write something that converts your string to the needed type.

So without any information about how the string is presented, i cant give you an helpfull answer.

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 ina · Jan 14, 2011 at 09:08 PM 0
Share

Say you have a string in the form of a Quaternion stringvar ="(0,0,0,1)" for example or Vector 3 (1,3,5) for example..

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

No one has followed this question yet.

Related Questions

[Unity 3D] How to detect if the game object is left right from the player? 0 Answers

How to Rotate like b.transform.rotation = Quaternion.Euler(x, y, z); ? 1 Answer

Get direction of moving sphere? 1 Answer

how to CORRECTLY position and rotate a gameobject in unity 2 Answers

How to make Canvas follow CameraRig [VR - HTC VIVE] 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