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 RAVaught · Jan 31, 2013 at 05:30 AM · javascriptpathfindingactionscript

Overload for method Not Compatible

I am working on a A* implementation, and I am down to one bug in my code that I can not for the life of me figure out. There error is:

 The best overload for the method 'Node.getId(UnityEngine.GameObject)' is not compatible with the argument list '(System.Type)'.

Here are the two scripts:

 #pragma strict
 import System.Collections.Generic;
 
     class Graph
     {
     
         var edges : List.<Edge> = new List.<Edge>();
         var nodes : List.<Node> = new List.<Node>();
         var pathList : List.<Node> = new List.<Node>();
         
         
         function Graph(){}
         
         /*================================================================================*/
         
         function AddNode(id : GameObject, removeRenderer : boolean, removeCollider : boolean)
         {
             var node : Node = new Node(id);
             nodes.Add(node);
             
             //remove colliders and mesh renderer
             if(removeCollider)
                 GameObject.Destroy(id.collider);
             if(removeRenderer)
                 GameObject.Destroy(id.renderer);
         }
         
         /*================================================================================*/
         
         function AddEdge(fromNode : GameObject,  toNode : GameObject)
         {
             var from : Node = findNode(fromNode);
             var to : Node = findNode(toNode);
             
             if(from != null && to != null)
             {
                 var e : Edge = new Edge(from, to);
                 edges.Add(e);
                 from.edgelist.Add(e);
             }    
         }
         
         /*================================================================================*/
         
         function findNode( id : GameObject)
         {
             for(var n : Node in nodes) 
             {
                 if(n.getId() == id)
                 {
                     return n;
                 }
             }
             return null;
         }
         
         
         
 






The issue appears to be in the findNode function. That function references another script pasted below:

 #pragma strict
 import System.Collections.Generic;
 
 class Node
 {
 
     var edgelist : List.<Edge>;
     var path : Node = null;
     var id : GameObject;
     var xPos : float;
     var yPos : float;
     var zPos : float;
     var f : float;
     var g : float;
     var h : float;
     var cameFrom : Node;
     
     function Node(i : GameObject)
     {
         id = i;
         xPos = i.transform.position.x;
         yPos = i.transform.position.y;
         zPos = i.transform.position.z;
         path = null;
     }
     
     function getId(id : GameObject)
     {
         return id;    
     }
 
 
 
 }


I have been beating my head against the wall on this for a while now. Any help you could offer would be greatly appreciated.

Regards, Tony

Comment
Add comment · Show 1
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 Julien-Lynge · Jan 31, 2013 at 05:49 AM 0
Share

Just a thought (not a JS expert): you don't seem to be specifying a return type on the getId function. If I remember my JS, that means it'll be expecting void and ins$$anonymous$$d getting a GameObject.

1 Reply

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

Answer by DaveA · Jan 31, 2013 at 06:08 AM

You call it like this:

 if(n.getId() == id) // take NO arguments, returns? (GameObject by looking at definition)

but it's defined like this:

 function getId(id : GameObject) // takes a GameObject returns ?

So, either don't have it defined to take any arguments, or pass in a GameObject when calling it.

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 RAVaught · Feb 04, 2013 at 03:16 AM 0
Share

Thanks for that. It sorted me out.

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

12 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

Related Questions

Unity is recording all info gathered from separate pathfinders into a single array. Why? (JS) 0 Answers

A* nodes in the basic version of unity. 1 Answer

AI Pathfinding Script 4 Answers

Need to change direction of transform? 2 Answers

Path finding using Raycasting inside of Unity(JavaScript) 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