Im looking to optimise my walljump, at the moment to check for walls i do two seperate raycasts on either side of the character, and I thought it might be more efficient to do it with a spherecast, however i have never worked with them and just now found out that you can input a direction to move the sphere in. Can i use spherecast without moving the sphere? And If i make the sphere a little bigger than my characters radius (the character is just a capsule) will the collisions/outputs be consistent?
A spherecast is like a raycast, just with a sphere. You are effectively firing a sphere through the world in the given direction, until it collides with something.
Like all ‘cast’ methods, if is already overlapping something, it won’t be picked up. That’s what all the ‘Overlap’ methods are for.
And you really shouldn’t worry about the performance of two raycasts vs one sphere cast. Neither on their own are ever going to be a performance concern. Just concern yourself with getting it working.
I guess I didn’t explain it correctly in my original question, but my issue is that since its only two raycasts, you can only walljump if the wall is directly on your right or left, but i would like to be able to walljump if im just touching the wall, no matter the direction or the way im facing, and i didnt know if it is smart to add even more raycasts all around the player
Again, a few raycasts is not a performance issue. If Unity couldn’t run a few raycasts within a frame, it wouldn’t be a useable engine. Get it working, worry about the details later.
And like I said, there are overlap methods to determine whether a collider is within a certain volume. You should look into said methods.