Hi, I’ve started learning Godot. On my first target I’ve choosen snake game but it’s axolotl with fish.
I launched some tutorial videos but… they are on Godot 3.0, on 4.0 version and I can’t find snake with TileMap.
I wrote this code and started to analyze but after some hours still don’t know what causes my error
“Nonexistent function size in base int” I’ve tried to look for repair for this error but every try finished with new errors…
It’s 28-29 line’s fault. Please for help. If you have better tutorials for Godot 4.0 for beginners I will be pleased too.
PS. I know about what “int” is etc but i don’t have knowledge how to repair this error in Godot. I am a little confused
on line 29, the insert function doesn’t return the new array, it only returns an error code (int) which you assigned to axolotl_body, that’s causing the issue
Thanks for help. @Monday Your solution works only partially. The code runs once, but the next loop causes another error and crash.
"Out of bounds get index ‘0’ (on base:‘Array[Vector2]’)
Maybe I have made too much mess in the code. I tried to add some own solution.
@Batiste thanks for the tips. I will try to develop my skills
if i understand correctly you’re trying to remove the last element of axolotl_body with slice? in that case i should be size() - 1 not -2.
it can be done like this, too: var body_copy = axolotl_body.slice(0, -1)
edit: also you can assign the result of slice back to to axolotl_body, no need to create a new array: axolotl_body = axolotl_body.slice(0, -1)
but if you think it’s cleaner your way then it’s fine