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
1
Question by Alp-Giray-Savrum · Sep 03, 2013 at 12:33 PM · arraydebug.logerror-handling

Move one of the objects selected from array ?

Hello Guys, I've been working on a script for 2 days but I coudn't handle. so my script is this;

 #pragma strict
 
 //List of ducks
 static var duckList : GameObject[];
 
 //Speed of Crocodile
 var speedCroco : float;
 
 
 function Start () {
 
 }
 
 function Update () {
 
 //Move to one of the ducks selected from Array
 transform.position = Vector3.MoveTowards (transform.position, duckList[Random.Range(0, duckList.Length)], speedCroco * Time.deltaTime);
 
 }

So Debug Log gaves me this error. "The best overload for the method 'UnityEngine.Vector3.MoveTowards(UnityEngine.Vector3, UnityEngine.Vector3, float)' is not compatible with the argument list '(UnityEngine.Vector3, UnityEngine.GameObject, float)'." I didn't understand what is it meaning ? So Please Help !

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 Fattie · Sep 03, 2013 at 01:05 PM 0
Share

Hi Alp,

One thing you should do:

do not use arrays. Use the system "List"

ie, with ...

using System.Collections.Generic;

please look around on here for many examples of it.

It's great to be 14, the perfect time to learn program$$anonymous$$g!

avatar image Alp-Giray-Savrum · Sep 03, 2013 at 01:22 PM 0
Share

Thank you so much ^_^ There's a short period remains to finish my first project for android platform, thanks for help :)

avatar image perchik · Sep 03, 2013 at 01:52 PM 0
Share

Fattie. Again, there you go with your blanket statements without proof.

System arrays are completely fine to use. Sometimes you need the other things that List provides, but for day to day simple usage, arrays are fine.

Stop making blanket statements about "Do not do " or "Never do___" without any kind of justification.

1 Reply

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

Answer by perchik · Sep 03, 2013 at 12:39 PM

Your error tells the answer.

With some spacing , the error says :

UnityEngine.Vector3.MoveForwards(UnityEngine.Vector3, UnityEngine.Vector3,

float) is not the same as the argument list
U

nityEngine.Vector3.MoveForwards(UnityEngine.Vector3, UnityEngine.GameObject,

float) Which means, MoveForwards takes in a Vector3, a Vector3 and a float, but you are passing in a Vector3, a GameObject and float. Your DuckList is an array of GameObjects, so when you get a random gameobject from the array, you can't just pass that gameObject to MoveForwards. Instead you probably want it's position which you access by .transform.position like this: transform.position = Vector3.MoveTowards (transform.position, //Vector3 duckList[Random.Range(0, duckList.Length)].transform.position, //Vector3 speedCroco * Time.deltaTime);//float Now, with that said, you might still get an error with the code you've provided since you don't ever assign anything to that array, but I'm hoping that the code you posted was just for the sake of demonstration.
Comment
Add comment · Show 3 · 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 Alp-Giray-Savrum · Sep 03, 2013 at 12:50 PM 1
Share

I'm sorry I couldn't understand :( Sorry for my bad english I'm from turkey and 14 years old. Could You explain it basicly ?

avatar image perchik · Sep 03, 2013 at 01:08 PM 1
Share

I updated my answer to make it more clear, but this is about as simple as I can get it

avatar image Alp-Giray-Savrum · Sep 03, 2013 at 01:16 PM 1
Share

It worked thank you very much sir :)

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

problem with FindWithTag 2 Answers

Assets/Scripts/connector_link.js(7,29): BCE0051: Operator '-' cannot be used with a left hand side of type 'UnityEngine.GameObject' and a right hand side of type 'UnityEngine.GameObject'. ERROR HELP! 1 Answer

HELP How to remove gameobject from Built-in Arrays 2 Answers

Array problem? help please! 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