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 mak · May 21, 2012 at 02:57 PM · c#convert

C# to Unity script question ?

Please help :) I need to convert this small piece of C# script into UnityJS ,im stuck for some reason :()

 // at top of ControlledCar.cs, within the class add
 public Joystick leftJS;
 public Joystick rightJS;
 
 // in Scenario select the Car and link the joysticks to the two new properties.
 // in FixedUpdate function replace the steer=… accel=… brake=… lines with something like this:
 steer = Mathf.Clamp(Input.GetAxis("Horizontal") + leftJS.position.x, -1f, 1f);
 accel = Mathf.Clamp(Input.GetAxis("Vertical") + rightJS.position.y, -1f, 1f);
 brake = Input.GetButton("Jump") || (rightJS.position.y < 0.95f);
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

4 Replies

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

Answer by mak · Jun 01, 2012 at 08:05 PM

ANSWERED - You have to use pragma strict for the Iphone or android my car runs perfectly now ,well it stops when its meant to lol ,.So the answer is convert all the Unity Car Tutorial to #Pragma Strict and it does actually work

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
2

Answer by Berenger · May 21, 2012 at 03:26 PM

Only two differences :

Variable declaration

C# : [protection level (default private)] [type] [name];

UnityScript : [protection level (default public)] var [name] : [type];

Floats

C# : 1f / 1.0f;

UnityScript : 1.0;

Comment
Add comment · Show 6 · 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 Eric5h5 · May 21, 2012 at 03:33 PM 2
Share

Actually you can use 1f / 1.0f in Unityscript, though there's no real reason to, since float, rather than double, is the default.

avatar image Berenger · May 21, 2012 at 03:34 PM 0
Share

Good to know, thanks :) Not sure I'll remember though.

avatar image mak · May 21, 2012 at 03:50 PM 0
Share

public Joystick leftJS; public Joystick rightJS;

It refuse to accept these in Js ?

Assets/Standard Assets/Scripts/Car.js(1,8): BCE0043: Unexpected token: Joystick.

Im still lost ,sorry im a noob scripter lol :p

avatar image Bunny83 · May 21, 2012 at 04:02 PM 0
Share

Ok just look at what you just (should have) learned:

 // C#
    public                                Joystick  leftJS;
    public                                Joystick  rightJS;
 // [protection level (default private)]  [type]    [name];
 
 // UnityScript
 // [protection level (default public)]  var  [name]  : [type];
    public                               var  leftJS  : Joystick;
    public                               var  rightJS : Joystick;

Was that so hard? I mean that's just "token replacement".

avatar image mak · May 21, 2012 at 05:38 PM 0
Share

Assets/Standard Assets/Scripts/Car.js(3,56): BCE0018: The name 'Joystick' does not denote a valid type ('not found').

is what I get now ? what am I missing please ?

Show more comments
avatar image
0

Answer by mak · May 22, 2012 at 03:24 AM

Done lol ,i went around it a completely different way :p

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 Berenger · May 22, 2012 at 04:10 AM 0
Share

Care to describe for posterity ?

avatar image
0

Answer by mak · May 23, 2012 at 08:31 AM

I dropped the Unity Car Tutorial demo completely ,as noone knows how to stop the car moving when it shouldnt ,so its a pointless exercise ....

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

convert to c# 2 Answers

Converting JS to C# 3 Answers

C# to UnityScript conversion help. 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