• 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 /
  • Help Room /
avatar image
0
Question by joshua-lyness · Dec 30, 2015 at 09:28 PM · vector3functionfunctionsidentifier

Vector3 not an identifier?

I am trying to write a function that finds a point on a Bezier curve. I need it to output a vector 3 co ordinate however it keeps giving me an error saying "identifier expected". Isnt the first phrase "Vector3" the identifier here!? heres a screenshot of some of the errors :/ alt text

     //function to find point on curve
     Vector3 curveEquation(p0 : Vector3, p1 : Vector3, p2 : Vector3, p3 : Vector3, t : float)
     private Vector3 p4;
     private Vector3 p5;
     private Vector3 p6;
     private Vector3 p7;
     private Vector3 p8;
     private Vector3 p9;
     {
         
         p4 = Vector3.Lerp(p0,p1,t);
         p5 = Vector3.Lerp(p1,p2,t);
         p6 = Vector3.Lerp(p2,p3,t);
         p7 = Vector3.Lerp(p4,p5,t);
         p8 = Vector3.Lerp(p5,p6,t);
         p9 = Vector3.Lerp(p7,p8,t);
 
         return p9;
     }
 }


screenshot-3.png (241.7 kB)
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 NoseKills · Dec 31, 2015 at 12:14 AM

1) you are mixing C# syntax with UnityScript syntax

 Vector3 curveEquation(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float  t)
 //not
 Vector3 curveEquation(p0 : Vector3, p1 : Vector3, p2 : Vector3, p3 : Vector3, t : float)

2) you cannot declare fields between a function declaration and that function's body { }

 private Vector3 p4; // <- a field, accessible in the whole class
 Vector3 curveEquation(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
 {
     Vector2 p5 // <- a local vector only accessible in this method 
     // your method stuff
 }
 // not
 Vector3 curveEquation(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
 private Vector3 p4;
 {
     // your method stuff
 }
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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

39 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with Contains 0 Answers

Need help making my code more efficient 0 Answers

Method Group 1 Answer

OnTriggerEnter not working 1 Answer

Having some problem with AI finding a vector3... 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges