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 laurienash · Jun 09, 2013 at 06:39 PM · rotationtransform

How to instantiate controller at specific rotation (Error: It is not possible to invoke an expression of type 'UnityEngine.Quaternion'

Hi - when my third person controller hits a collider, he is destroyed, and a new third person controller is instantiated in the exact same position. However - I also want him to be rotated 180 degrees (so facing backwards).

This is the line of code that is giving me an error: carl.transform.Rotate (0, 180, 0); Do you know what I'm doing wrong?

This is the script to instantiate a new third person controller (JavaScript):

 var carl : GameObject;
 var vincentCamera : GameObject;
 var thirdPerson : GameObject;
 var script : SwitchCharacters;
 var playerGO : GameObject;  
 private var hasPlayed = false;
 
 var characterPosition : Vector3;
 
 function Start () {
 
 carl.SetActive (false);
 vincentCamera.SetActive (false);
 
 }
 
 
 function OnTriggerEnter () {
 
 
 if (!hasPlayed&&!thirdPerson.active){
 
 characterPosition = GetComponent(DestroyCharacter).firstCharacterPosition;
 
 carl.transform.position = characterPosition;
 carl.transform.Rotate (0, 180, 0);
 
 carl.SetActive (true);
 vincentCamera.SetActive (true);
 
 
 
 script.cam02 = carl.Find("VincentCamera");
 
 
 script = playerGO.GetComponent(SwitchCharacters);
 script.player02 = carl;
 
 
 hasPlayed = true;
 
 }

Any help on how to fix the error would be so much appreciated! The error is BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Quaternion'.

Thanks, Laurien

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ExTheSea · Jun 09, 2013 at 07:01 PM

You have to do:

 carl.transform.Rotate(new Vector3(0, 180, 0));

as can be seen here too: http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html

Comment
Add comment · Show 4 · 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 InfiniBuzz · Jun 09, 2013 at 07:08 PM 0
Share

Doesn't one overload allow 3 float values?

avatar image ExTheSea · Jun 09, 2013 at 07:17 PM 0
Share

Right i just noticed that. Hm in this case if this doesn't work i would suggest just to use something like this:

 carl.transform.rotation = new Vector3(0,180,0);

When you use transform.rotate you normally multiply the value by Time.deltaTime or similar to get a smooth rotation-effect. $$anonymous$$aybe the method is complaining because of that.

avatar image iwaldrop · Jun 09, 2013 at 10:55 PM 0
Share

Transform.rotation is a quaternion, not a vector3. In order to set the rotation of a transform, either supply a quaternion that has been derived from some calculation (I.e. don't modify xyzw values of quaternions directly), or set transform.eulerAngles wih a vector3 ins$$anonymous$$d.

avatar image laurienash · Jun 09, 2013 at 11:16 PM 0
Share

Yes I had read that - I didn't realise you needed to add the new Thanks!

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

17 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

Related Questions

C# Need Help Refining Ricochet Script 1 Answer

[SOLVED]Possible Alternation of Transform.Rotate 1 Answer

Change Pivot Point- Maya 3 Answers

Min-Angle Constraint Script Causes Jitter 0 Answers

Camera rotation C# script problem 3 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