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 codemypantsoff · Mar 31, 2013 at 07:01 AM · vector3quaternion

Quaternion and Vector3

I am lost on why i get

'Assets/Scripts/Move_Camera.cs(42,67): error CS0119: Expression denotes a type', where a variable', value' or method group' was expected'

With the following code - I am still new to Unity so be gentle :)

 Quaternion Targetrotation = Quaternion.Euler(y, x, 0);
 Vector3    Targetposition = Targetrotation * Vector3(Targetrotation) * Vector3(0.0, 0.0, -distance) + target.position; 

    
Comment
Add comment · Show 6
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 Chronos-L · Mar 31, 2013 at 07:34 AM 0
Share

Vector3(TargetRotation) will not work because the Vector3 constructor doesn't take Quartenion as parameters.

Vector3(0.0, 0.0, -distance) will not work because it is missing the new keyword.

avatar image Fattie · Mar 31, 2013 at 11:40 AM 0
Share

there is something to be said for simply not using Quaternions at all, ever, unless you have a lot of expertise with them.

Be sure to look at the super-simple and amazing commands .Rotate and also the very handy .RotateAround

(I'm intrigued by the question, can one do everything without every using Quaternions? I don't know.)

avatar image whydoidoit · Mar 31, 2013 at 11:44 AM 0
Share

Quaternions are very handy when you want to combine rotations - like orient an object's up to a surface normal etc. Harder to do that with Eulers, quite possibly not possible!

avatar image Fattie · Mar 31, 2013 at 12:05 PM 0
Share

we need $$anonymous$$r Turing to tell us eh ! :)

good point on combining rotations. perhaps good advice for beginners is "stick with .Rotate until you get to the point of needing to combine rotations"

To clarify my point: I believe there's an effect where beginners happen to see certain "advanced terms" and they incorrectly think those advanced concepts are necessary to achieve something very simple.

(I think there was an example yesterday. I think someone just needed to know how to get a random number ("Random.Range(1,7)") but, incorrectly though they had to do something with mersenne twisters or the like.)

There should be a term for this phenomenon! Where someone trying to solve a software problem (where, in fact, a trivial commonplace high-level solution exists today) is distracted by an arcane term and incorrectly thinks they must learn about / work at a much lower, more complex, level.

(I was guilty of a somewhat similar thing the other day, I thought a client wanted a whole sort of server-based social interaction system. I had utterly misunderstood, all they wanted was a button in the app that opened a browser with a certain URL !! :O )

avatar image codemypantsoff · Mar 31, 2013 at 01:31 PM 0
Share

Thanks for the comments - actually this is a convert from JS to C#

here is the full piece - that works

function LateUpdate () { if (target) { x += Input.GetAxis("$$anonymous$$ouse X") xSpeed 0.02; y -= Input.GetAxis("$$anonymous$$ouse Y") ySpeed 0.02;

      y = ClampAngle(y, y$$anonymous$$inLimit, y$$anonymous$$axLimit);
             
     var rotation = Quaternion.Euler(y, x, 0);
     var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
     
     transform.rotation = rotation;
     transform.position = position;
 }

}

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Wiki

Answer by Kolkina · Mar 31, 2013 at 10:29 AM

http://answers.unity3d.com/questions/8472/help-with-error-expression-denotes-a-type-where-a.html

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 whydoidoit · Mar 31, 2013 at 10:34 AM

Firstly it's the lack of new as @Kolkina says. Your next problem is that you are trying to multiply Vector3s - you can't do that. And you certainly can't do Vector3(TargetRotation) - what does that mean?

I think what you want to do is:

 var targetPosition = (targetRotation * Vector3.forward * distance) + target.position; //or maybe - distance

Vector3.forward is (0,0,1). You can multiple the quaternion by the vector and the vector by the scalar.

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

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

15 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

Related Questions

Perpendicular Vector3 0 Answers

c# modify only one axis of a quaternion 2 Answers

Unity's equivalent of Vector3.Transform(...) 2 Answers

How Make an Vector Follow an Quaternion? 1 Answer

Help with Quaternions and Vector3s 2 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