Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by KeithSeraph · Sep 13, 2016 at 06:45 AM · c#transformbuttonvector3integer

(26,47): error CS1525: Unexpected symbol `)'

I was trying to script an object to move to a different position when the player presses the right button, i based it off of integers because the script would be attached to multiple objects with different set locations. The script basically increases the integer when the right button is pressed and that integer changes the object to its next position based off of that integer. I could also use help giving the integer a range of 1 to 4. I keep getting (26,47): error CS1525: Unexpected symbol `)' and also one on line (31,47)

 using System.Collections;
 
 public class menugun : MonoBehaviour {
 
     public int position;
     public Vector3 startPosition;
     public Vector3 secondPosition;
     public Vector3 thirdPosition;
     public Vector3 fourthPosition;
     public Animator anim;
     public Button rightArrow;
     public Button leftArrow;
 
     // Use this for initialization
     void Start () 
     {
         anim = GetComponent<Animator>();
         rightArrow = rightArrow.GetComponent<Button> ();
         leftArrow = leftArrow.GetComponent<Button> ();
         position = 0;
     }
 
 
     void RightPress()
     {
         anim.SetInteger("position", ++);
     }
 
     void LeftPress()
     {
         anim.SetInteger("position", +-);
     }
 
 
     void Update () 
 {
         if (position = 0) 
         {
             transform.localPosition = startPosition;
         }
             
         if (position = 1)
         {
             transform.localPosition = secondPosition;
         }
 
         if (position = 2) 
         {
             transform.localPosition = thirdPosition;
         }
     
         if (position = 3) 
         {
             transform.localPosition = fourthPosition;
         }
     }
 }












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
0
Best Answer

Answer by Namey5 · Sep 13, 2016 at 06:55 AM

Well, if you are doing a comparison you shouldn't be setting values.

 Should be
 
 if (position == 0)
 
 Rather than
 
 if (position = 0)

And I'm not particularly sure if you can assign an increment to a function. You may be able to, but I would do it;

 int animPos = 0;

 void RightPress()
 {
     animPos++;
 }

 void LeftPress()
 {
     animPos--;
 }
  
  
 void Update () 
 {
     animPos = Mathf.Clamp (animPos, 1, 4);    //Will set a range for the int from 1 to 4
     anim.SetInteger ("position", animPos);
 }
Comment
Add comment · Show 1 · 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 KeithSeraph · Sep 13, 2016 at 07:19 AM 0
Share

Thanks it worked

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Moving GameObject a specific distance in the Z direction and back again - regardless of rotation 1 Answer

Move gameObject on UI Button Press 2 Answers

Set variable to position of collided object. 0 Answers

I got Some Error about how to Transform Postiton Enemy where one point can spawn 2 enemies. 1 Answer

Turn Based Movement - Using Movement Points 0 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