Hi, I’m currently working on a 2D slingshot game. I’m using the player transform and a Direction transform in front of the player to draw a Raycast to detect where the player should go but after I moved the first time it just not working at all.
I recorded a short clip to show the error:
You named your variable “direction” but that doesn’t make it a direction, it’s a point in space.
Here’s the docs for Physics2D.Raycast. The 2nd argument is a direction not a position in space. In your case it’s a normalized “direction - startPos” but be careful here as those are 3D vectors. You should use 2D vectors otherwise any differences in Z can throw it out.
Thx, but I still don’t quite know how to do it. Im completely new to raycasts and vectors and stuff so a small example would be nice.
And Im using Vector2, aren’t they 2D Vectors?