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 Laurentiu963 · Oct 02, 2014 at 01:22 AM ·

What does that mean? "BCW0008: WARNING: Duplicate namespace: 'UnityEngine'"

That is my conde.. What is wrong?

 import UnityEngine;
 
 import System;
 
 class PlayerController extends MonoBehaviour
 
 {
 
 var speed = 800.0;
     
     function FixedUpdate() {
         var moveHorizontal : float = Input.GetAxis ("Horizontal");
         var moveVertical : float = Input.GetAxis ("Vertical");
         
         var movement = Vector3(moveHorizontal, 0.0, moveVertical);
         
         rigidbody.AddForce(movement * speed * Time.deltaTime);
     }
 }
 

It gives me that Warning "BCW0008: WARNING: Duplicate namespace: 'UnityEngine'" and i cant move my player.

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

2 Replies

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

Answer by Landern · Oct 02, 2014 at 02:11 AM

By default using UnityEngine(c#) or import UnityEngine(unityscript) and System.Collection.Generic are automagically added to the top of the script but you don't see it. So yes, it is duplicated since you explicitly added them. Go ahead and remove your import for UnityEngine.

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 Laurentiu963 · Oct 02, 2014 at 03:20 AM 0
Share

Ok :) thank you

avatar image
-1

Answer by graviton · Oct 02, 2014 at 03:20 AM

Are you trying to mix Unity Java and C#?

You can't mix Java and C#

import UnityEngine; (Wrong)

import System; (Wrong)

class PlayerController extends MonoBehaviour (Wrong)

var speed = 800.0; (Wrong)

function FixedUpdate (Wrong, this is Java)

I fixed your code, it's in C#

 //Make sure you Freeze the X and Z Rotations on the Rigidbody!
 //Make sure your script is also called "PlayerController"!
 
 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour 
 {
    
     public float speed = 800f;
     
         
     void FixedUpdate() 
     {
     
     float moveVertical  = Input.GetAxis("Vertical");
     float moveHorizontal = Input.GetAxis("Horizontal");
     Vector3 movement = new Vector3 (moveHorizontal, 0f, moveVertical);    
     rigidbody.AddForce(movement * speed * Time.deltaTime);
     
     }
 
 }

Your code in Java

 #pragma strict
 
 var speed = 800.0;
 
 function FixedUpdate() 
 {
     var moveHorizontal : float = Input.GetAxis ("Horizontal");
     var moveVertical : float = Input.GetAxis ("Vertical");
     
     var movement = Vector3(moveHorizontal, 0.0, moveVertical);
     
     rigidbody.AddForce(movement * speed * Time.deltaTime);
 }
 

Hope this help

Comment
Add comment · Show 5 · 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 Laurentiu963 · Oct 02, 2014 at 11:22 AM 0
Share

Fixed that :) thank you

avatar image Landern · Oct 02, 2014 at 02:17 PM 0
Share

@graviton, the op was using UnityScript(it's not java, it's not javascript, though some syntax is shared, yes it's called JS in the docs, but we know it's not).

The OP code was correct and yes you can create classes in unityscript and yes you can extend(inherit/derive) from other classes. It may look like c# given some of the keywords used, but they are just shared. Take a gander at the tutorials on classes, you don't need to watch the video, just switch the example code to JS(unityscript).

Yes i realize it's marked as JS/JavaScript all over unity's docs and site, but calling it java it taking the confusion a step further. It's agreed it was a poor decision to call it javascript. In monodevelop you create UnityScripts, in the editor you create JavaScript...

avatar image graviton · Oct 03, 2014 at 12:02 AM 0
Share

@Landern "UnityScript(it's not java, it's not javascript"

I didn't say it was, I know Unity Java is not the same as Java Script, that's why right at the top I wrote "Are you trying to mix Unity Java and C#?", "Unity Java", understand "Unity Java"

"Laurentiu963" didn't state whether he was trying to write his code in Java (yes Unity Script) or C#

I just assumed that he was trying to write a C# script and got mixed up, wrote Java's "import UnityEngine;" but in fact meant to write C#'s "using UnityEngine;"

I think you are way too hung up on all this "Unity Java (Unity Script) shouldn't be called Java" business

You know people here are going to keep calling it Java right?

avatar image tanoshimi · Oct 03, 2014 at 06:56 AM 1
Share

I have to agree with @landern on this. There's no point having this site designed to help people learn how to use Unity if it contains confusing, inaccurate information. We didn't make the Java/Javascript/Unityscript nomenclature mess, but we shouldn't continue to propagate it unnecessarily.

I'm not so bothered about the Javascript/Unityscript distinction, but Java is a completely different thing. I have seen several questions on this site along the lines of "What is the best book I should buy to help me learn Java for Unity", which is going to lead to a lot of disappointed purchases. It also makes it very hard to identify those occasional questions that really are about Java (e.g. server-side or Android plugins).

avatar image graviton · Oct 04, 2014 at 01:32 AM 0
Share

@tanoshimi

inaccurate?

propagate?

I'm not propagating anything

It's like you guys are only reading what you want to hear

Wrong as it may be, Unity are calling it Java here and in the documentation, calling it something else isn't going to change that

Whether you like it or not people here are still going to keep calling it Java

That's enough trolling out of you, this isn't a forum

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

How to make a GUI.box pop up under an if statement (new to programming) 1 Answer

How to make enemy slowly run to player 1 Answer

How to add play again or quit dialog 1 Answer

CS0029 convert type 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