Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 AASonyKK · Sep 05, 2011 at 08:54 PM · c#

Script from JS to C#

I need to translate an object form A to B. I found this http://www.unifycommunity.com/wiki/index.php?title=MoveObject and it work fine but i need to convert it in C#.

If I understand the MoveObject.js can remain in js but I can't convert the example to C#

The example is it:

 function Start () {
 // Starting from the origin, move this object to 5 units along X by 10 units along Z, at 2.5 units per second
 yield MoveObject.use.Translation(transform, Vector3.zero, Vector3(5.0, 0.0, 10.0), 2.5, MoveType.Speed);
 // When that's done, simultaneously move up one unit and flip 180 degrees along the Z axis, doing both in half a second
 MoveObject.use.Translation(transform, Vector3.up, .5, MoveType.Time);
 MoveObject.use.Rotation(transform, Vector3.forward * 180.0, .5);

}

I read in C# I must write StartCoroutine, but I can't do it.

Can any help me? Thanks

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 SilverTabby · Sep 05, 2011 at 10:04 PM

 IEnumerator Start ()
 {
     // Starting from the origin, move this object
     // to 5 units along X by 10 units along Z, at 2.5 units per second
     yield return StartCoroutine
        (MoveObject.use.Translation
            (transform, Vector3.zero, Vector3(5.0, 0.0, 10.0), 2.5, MoveType.Speed));

      // When that's done, simultaneously move up one unit
      // and flip 180 degrees along the Z axis, doing both in half a second
     StartCoroutine(MoveObject.use.Translation(transform, Vector3.up, .5, MoveType.Time));
     StartCoroutine(MoveObject.use.Rotation(transform, Vector3.forward * 180.0, .5));
 }




StartCoroutine(method) --- Creates a coroutine that runs side by side this one

yield return ____________________________________________;

  • null //waits for one frame to pass and resumes during the Update calls

  • break //kills this coroutine immediately.

  • StartCoroutine(nameOfCoroutine()) //waits for nameOfCoroutine to finish

  • new WaitForSeconds(X) //waits for X seconds

  • new WaitForFixedUpdate() // waits for one frame to pass and resumes during the FixedUpdate calls

Comment
Add comment · Show 2 · 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 AASonyKK · Sep 05, 2011 at 10:31 PM 0
Share

I use this code but i take a lot of errors because the script can't find the $$anonymous$$oveObject. I did this "Put this script in your Standard Assets/Scripts folder; this way it can be easily used from C# or Boo. The script should be named "$$anonymous$$oveObject". The script must be attached to some object in the scene, such as an empty object used for game manager scripts" and i created a new c sharp script and I use the your answer but it don't run. But if i use the js script it work. I used:

using UnityEngine; using System.Collections;

public class Person1$$anonymous$$ove : $$anonymous$$onoBehaviour {

 IEnumerator Start() .......

And I take the error "The name `$$anonymous$$oveObject' does not exist in the current context"

Can this error appear beacuse the us script is in c# and the $$anonymous$$oveObject is in JS? mmmm I need help!

I think now the question is: How can I create a C# script that can communicate with another js script? (because the $$anonymous$$oveObject is in JS.

avatar image AASonyKK · Sep 06, 2011 at 12:36 PM 0
Share

SOLVED!!!

The C# script for see the $$anonymous$$oveObject js script, I had to put the js script in the "Standard Assets" and not in "Standard Assets-->Scripts"

Thanks for the help!!!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Error when referencing one script from another. 1 Answer

Reference a JS script in a C# script? 2 Answers

Distribute terrain in zones 3 Answers

how can convert this in js? 1 Answer


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