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 SOIL · Aug 01, 2010 at 08:28 AM · errorsyntax-errorcs8025cs0029

Compile Errors for Script

i get an parsing error on this:

using UnityEngine; using System.Collections;

public class MoveForwardwithMouseClick : MonoBehaviour {

void FixedUpdate() { if (Input.GetAxis("Fire1")) { rigidbody.AddForce(transform.forward rigidbody.velocity 2f); } }

Assets/Scripts/MoveForwardwithMouseClick.cs(11,1): error CS8025: Parsing error

i want to thurst a rigidbody forward to it's z-axis with an upwarding speed by pressing the left mouse button.

I closed the lines and get now other errors:

public class MoveForwardwithMouseClick : MonoBehaviour {

     void FixedUpdate() {
         if (Input.GetAxis("Fire1")) { 
         rigidbody.AddForce(transform.forward * rigidbody.velocity * 2f);
         }   
     }
 }

error CS0029: Cannot implicitly convert type float' tobool'

error CS0019: Operator *' cannot be applied to operands of typeUnityEngine.Vector3' and `UnityEngine.Vector3'

O_O

Comment
Add comment · Show 3
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 qJake · Aug 01, 2010 at 08:36 AM 0
Share

It would be helpful if you pasted the actual error, since it usually tells you exactly what's wrong. That, or you don't have a closing }, I don't know if you just missed that when you pasted your script in here or not.

avatar image _Petroz · Aug 01, 2010 at 08:47 AM 0
Share

I think the missing closing '}' for the class is the error.

avatar image qJake · Aug 01, 2010 at 09:32 AM 0
Share

Fixed your errors. See post below.

1 Reply

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

Answer by qJake · Aug 01, 2010 at 09:32 AM

Okay, two problems.

First: GetAxis returns a number, and you can't if(number).

if (Input.GetButton("Fire1"))

Second: You can't multiply two vectors together. I think you probably wanted this instead:

rigidbody.AddForce(transform.forward * 2f);

You don't need the velocity at all, since AddForce calculates the Dot Product for you, combining the vectors with physics magic. :)

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 SOIL · Aug 01, 2010 at 09:36 AM 0
Share

Thnx SpikeX!! Now the script works! :D juhee

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

Quiz Scoreboard 2 Answers

How do i rearrange this in C(sharp)? 0 Answers

Getting list music array 1 Answer

[Closed] Getting CS0029 error when I try to check position of an object 1 Answer

help with a random battle generator? 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