the script you posted is java, not C# that’s why you can’t get it to work.
I’ve converted it for you. I hope I didn’t miss anything. I didn’t test the code
When I press play my butterfly however disappears, not sure if its position just automatically transforms to something totally different, but I can´t find it.
Ya, no idea what happened. Is it possible that it’s under your ground/terrain or inside something?
If you click it in the hierarchy but still can’t find it, that is a mystery to me lol. I would look at its position there, and then compare that to the ground/terrain level… and if that doesn’t explain it, I’m not sure.
So I updated the script with the lines you gave me.
It seems something is still wrong. The position of the butterfly starts at a very high value position and then drops to lower numbers, also after a certain time it just freezes at a random position with lower numbers.
You modified the code to include "transform.position.x + / - 2 "
I tested your code and it went insane lol
transform.Translate moves relative to self, so when you keep adding transform.position as part of the target, it grows out of control.
I’m testing it right now, and I don’t know exactly what you want, but you could keep the translate as target * 10 or change the number 10 to be a bit smaller. (and remove the transform.position parts).
It seems to be better than the other. Not sure if you want some kind of position clamping also, on any axis so it doesn’t go too far in any 1 particular way.