Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8022011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:09:01+00:00 2026-06-04T22:09:01+00:00

I’m a budding programming enthusiast and game designer studying to finish my degree, and

  • 0

I’m a budding programming enthusiast and game designer studying to finish my degree, and thus am still quite new in the world of programming. I’ve done a fair amount of JavaScript (actually UnityScript) and now am trying to dabble in C#. I have been following hakimio’s tutorial of making a turn-based RPG in Unity, which is based on a hexagon grid using A* pathfinding. (http://tbswithunity3d.wordpress.com/)

My question is that I have followed his tutorial step-by-step up to the point of finishing the A* pathfinding scripts and assets, but have come across the error in Unity:

“error CS0308: The non-generic type `IHasNeighbours’ cannot be used with the type arguments”

This is the code that sparks the error message, on the line public class Tile: GridObject, IHasNeighbours<Tile>:

using System.Collections.Generic;
using System;
using System.Linq;
using UnityEngine;

public class Tile: GridObject, IHasNeighbours<Tile>
{
public bool Passable;

public Tile(int x, int y)
    : base(x, y)
{
    Passable = true;
}

public IEnumerable AllNeighbours { get; set; }
public IEnumerable Neighbours
{
    get { return AllNeighbours.Where(o => o.Passable); }
}

public static List<Point> NeighbourShift
{
    get
    {
        return new List<Point>
        {
            new Point(0, 1),
            new Point(1, 0),
            new Point(1, -1),
            new Point(0, -1),
            new Point(-1, 0),
            new Point(-1, 1),
        };
    }
}
public void FindNeighbours(Dictionary<Point, Tile> Board, Vector2 BoardSize, bool EqualLineLengths)
{
    List<Tile> neighbours = new List<Tile>();

    foreach (Point point in NeighbourShift)
    {
        int neighbourX = X + point.X;
        int neighbourY = Y + point.Y;
        //x coordinate offset specific to straight axis coordinates
        int xOffset = neighbourY / 2;

        //if every second hexagon row has less hexagons than the first one, just skip the last one when we come to it
        if (neighbourY % 2 != 0 && !EqualLineLengths && neighbourX + xOffset == BoardSize.x - 1)
            continue;
        //check to determine if currently processed coordinate is still inside the board limits
        if (neighbourX >= 0 - xOffset &&
            neighbourX < (int)BoardSize.x - xOffset &&
            neighbourY >= 0 && neighbourY < (int)BoardSize.y)
            neighbours.Add(Board[new Point(neighbourX, neighbourY)]);
    }

    AllNeighbours = neighbours;
}
}

Any help or insight on how to get past this error would be greatly appreciated, I’ve struggled over this script for the past few days trying to get it to work, and can’t proceed with the tutorial (and my project) with the error.

Thanks in advance everyone!

Aaron 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:09:03+00:00Added an answer on June 4, 2026 at 10:09 pm

    The problem will be that IHasNeighbours is not a generic interface so you can’t pass in a class to it the way you have passed the Tile class.

    Either you need to modify your IHasNeighbours interface to make it generic or you need to take out that reference to the Tile class after it. The solution will depend on what you need your code to do. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.