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
2
Question by Rydrako · Dec 23, 2010 at 10:42 PM · erroritweensyntax-errorcs0119

Can you help me solve my C# script error?

Hello again everyone! I'm a javascript person but, I can only script with iTween paths with C# and I don't know much about C#.

I get this weird error that says...

error CS0119:

Expression denotes a "type", where a "variable", "value" or "method group" was expected

...and I know it's referring to the following code:

if(cam.transform.position==Vector3(0,-457.5542,599.0647))


Here's the script I'm having problems with for sake of completeness:

using UnityEngine; using System.Collections;

public class ShowMap1 : MonoBehaviour {

public int time = 5; private bool playClip = false; private bool trig = false; public GameObject cam; public GameObject planet;

void Update () { cam = GameObject.Find("Main Camera"); planet = GameObject.Find("Planet"); if(playClip) { iTween.MoveTo(cam, iTween.Hash("path" , iTweenPath.GetPath("camPath"), "time", time)); playClip = false; } if(trig) { cam.transform.LookAt(planet.transform.position); } if(cam.transform.position==Vector3(0,-457.5542,599.0647)) { Application.LoadLevel(8); } }

void OnTriggerEnter (Collider collider) { cam = GameObject.Find("Main Camera"); if(collider.tag == "Player") { Destroy(GameObject.Find("MiniMapCamera").gameObject); Destroy(cam.GetComponent("SmoothFollow")); playClip = true; trig = true; } } }

Comment
Add comment · Show 1
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 Statement · Dec 23, 2010 at 10:52 PM 1
Share

Finally someone who actually paste the piece of code that is throwing the error! :)

1 Reply

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

Answer by Statement · Dec 23, 2010 at 10:50 PM

You must use the new keyword in C# when creating new instances. Also, you're feeding double values where expected single.

//                            v-- Here!              v---------v-- floating point
if (cam.transform.position == new Vector3(0,-457.5542f,599.0647f))

Nothing more than a slight difference in how C# and JS go about its business. Just tuck it to the back of your head if you get errors like those, check if you should use new.

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 Rydrako · Dec 24, 2010 at 01:02 AM 0
Share

I did that, but I still have errors. If I change the Vector3 statement into shorter numbers, they're gone, but I can't change the numbers becuase my iTween path only brings my camera to (0,-457.5542,599.0647) and not to (0,-460,600) like I set it to be.

avatar image Jesse Anders · Dec 24, 2010 at 01:11 AM 0
Share

@Game Hound: Whenever you ask for help with errors, you need to post the errors; otherwise, all we can do is guess as to what might be wrong (and sometimes we can't even do that). Also, keep in $$anonymous$$d that due to floating-point error, you can't always expect to get exactly the values you're expecting (e.g. 0, -460, 600).

avatar image Statement · Dec 24, 2010 at 01:47 AM 0
Share

That's because Vector3 operates on singles (float) and not doubles. I have corrected my post. (You need to tuck a "f" at the end of the decimal to denote floating point precision)

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

What does this mean ? 1 Answer

Having difficulty with semicolons. 2 Answers

Attack a Target (using mouse over?) 1 Answer

HELP BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Vector3'. 1 Answer

Script error. Please Help! 4 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