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
-1
Question by TheJayyBe · Dec 24, 2012 at 05:40 PM · gameobjectrotate

Transform.rotation problems

**H**ello. I can't insert GameObjects atached to an script of other GameObjects with the correct rotation:

The structure of whole thing is: An script atached to GameObjects 'parede'(wall), inside this script I have a function called insereRevestimento()(something like insert lining that insert gameObjects in this wall).

GameObject parede-->paredeProperties.cs-- >insertLining();

 public class PropriedadesParede : MonoBehaviour {
 
 public GameObject revestimento;
 
 insertLining(){    
 
     revestimento.transform.position=new Vector3(pontoInicialX+ 
 larguraDoRevestimento/2 +larguraInserida,
 pontoInicialY+comprimentoDoRevestimento/2 +comprimentoInserido,
 transform.position.z+revestimento.transform.localScale.z*2);
     
     
 // --> This part:
                 
             revestimento.transform.Rotate(0,90,0);            
             Instantiate(revestimento);        
             revestimento.transform.Rotate(0,90,0);}
 }


The natural rotation is (0,0,90) so I thing it must give for me the result (0,90,90), but it returns (-0.0005,270!,93). I am questioning me if the rotation of GameObject that the script is attached is affecting the final result, despite of the fact if I instantiate without Rotate the angle keeps the original, without interference. If is it, there is a way to rotate based on the angle global standard?

Comment
Add comment · Show 2
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 MaGuSware™ · Dec 24, 2012 at 06:01 PM 1
Share

Have you tried instantiating it WITH a position and rotation.

Instantiate(GameObject,Vector3,Quaternion); <---

avatar image TheJayyBe · Dec 27, 2012 at 07:08 PM 0
Share

I will try.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jogo13 · Dec 24, 2012 at 06:02 PM

You are instantiating a new Gameobject but not 'capturing' the returned new gameobject: Try this:

 GameObject newGO = Instantiate(revestimento) as GameObject;
 newGO.transform.Rotate(0,90,0);
 
 

You may want to use '`tranform.EulerAngles`' instead of Rotate http://docs.unity3d.com/Documentation/ScriptReference/Transform-eulerAngles.html

Comment
Add comment · Show 3 · 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 TheJayyBe · Dec 26, 2012 at 02:05 AM 0
Share

Sorry it does not work,

I tryed: GameObject instanciaRevestimento = Instantiate(revestimento) as GameObject; instanciaRevestimento.transform.Rotate(0,90,0);

with a natural prefab with properties (0,0,90) so I think result must be (0,0,90) but it's setting (270,0,90)

avatar image jogo13 · Dec 26, 2012 at 07:12 AM 0
Share

this should work: instanciaRevestimento.transform.rotation = revestimento.transform.rotation;

avatar image TheJayyBe · Dec 27, 2012 at 02:20 AM 0
Share

No man, it's not my intention to copy its rotation.

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

10 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

Related Questions

rotate to swip direction 0 Answers

C# Rotate GameObject at Other Point other than Center 3 Answers

RaycastAll isn't finding all possible collisions 1 Answer

How get the rotation of an GameObject? 3 Answers

Rotate around a locally tilted axis?, 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