Operator '-' error

hi im getting this error and i cant fix it.I compared with the one on GtiHub and cant find the solution
Assets\Scripts\Pathfinding.cs(108,45): error CS0019: Operator ‘-’ cannot be applied to operands of type ‘GridPosition’ and ‘GridPosition’

thx and good job Hugo and GameDevTV im enjoying all the courses i buyed

Hi @Leo_Powa. Welcome to the community

Did you override the operator? Can you show it? Perhaps there’s something wrong with it

sorry i dont understand what you mean im not really good at coding,but i made the script myself then the error showed up since i wroted the line,then i copied the Git resource and the problem is still there,the script is now like the resource

When we made the GridPosition struct, we overrode the ‘+’ and ‘-’ operators. This lets C# know how to add and subtract one GridPosition to/from another. You would have done that if you have a GridPosition struct and you followed the course. If you did that, show the GridPosition code so we can have a look at it

1 Like

thank you!!the problem was there on GridPositon.Im still fighting with the structs bcz im quite new on coding

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.