I'm trying to make a VR climbing game where you can climb if an object is climable. I'm going for gameplay like the climbing in vade imortal or the climb. But haven't been able to find any good climbing scripts. I tried using VRTK but it messes up the oculus quest. So I want to code my own script that only uses oculus utilities. Any suggestions or pointers would be helpful.
There will be lots of fine tuning required to the below to make it smooth and obviously I haven't built or testing any of the below but pretty sure it will get you started
Here is what I would do if I was looking at building a climbing game
For the player Add a capsule collider to the player object with a rigidbody and gravity turned on. That should take care of the player falling if they let go.
For the hands Add some sphere colliders or capsule colliders to the hands whichever you prefer Add a rigidbody with isKinematic turned on (you'll need that for the onTriggerStay) Add a script with a onTriggerStay function in that function add something to check if the object the hands are colliding with is a climbable object. If the intersecting objects is marked as climbable and the grip trigger is active then turn off the player gravity Move the position of the player based on how far the hands move up/down/left/right/forward/backwards that should move the player based on how you are moving the hands, this movement will be shaky as the position updates often so I would look to smooth that movement value out. When the player releases the grip turn gravity back on (only if the other hand isn't connected to a climbable object)
Some extra things to consider here
If the player currently has both hands attached to a climbable object you will want to limit the motion so the player can't move in weird ways, maybe a limit on the distance allowed between the two hand
You will need to allow in your script if it is a left or right hand so you can base your calculations off the correct controller.
If the player is only holding on with one hand, you probably don't want to let them extend out from the wall too far before loosing grip
Similarly if they player tries to move into the wall you will want to stop them
When the grip is applied, if you are using the avatar you will want to hide the hand so it doesn't move when the player is gripping/climbing
Add some stamina decrease while only holding on with one hand, if the stamina depletes remove the grip
If the player lets go with one hand and the other hand is far to one side, you may want to swing the player slightly closer to the gripping hand
For the climbable objects Add a collider Give the object a tag like "Climbable" (use that to detect if the item to players hands is intersecting with is a climbable object
For the head You'll want something that fades out the view if the players head intersects the climbing wall other wise they will be able to go through the wall Add a collider and do a similar check on the hands if the head intersects the collider of the wall then fade in/out a plane/quad in front of the camera to let the player know to move their head back
I would test- using collission instead of tiggers and set up the physics collision matrix for the hands/head/climbable objects, that may be more performant than a comparetag, however its unlikely you will have so many collisions and compare tags that it would kill the performance, but if you are targeting the quest you will want to limit the overhead as much as possible.
Hope that gets you started at least Its a reasonably difficult task to setup a good climbing script but pretty easy to setup a simple one that you can then expand on, best of luck
There will be lots of fine tuning required to the below to make it smooth and obviously I haven't built or testing any of the below but pretty sure it will get you started
Here is what I would do if I was looking at building a climbing game
For the player Add a capsule collider to the player object with a rigidbody and gravity turned on. That should take care of the player falling if they let go.
For the hands Add some sphere colliders or capsule colliders to the hands whichever you prefer Add a rigidbody with isKinematic turned on (you'll need that for the onTriggerStay) Add a script with a onTriggerStay function in that function add something to check if the object the hands are colliding with is a climbable object. If the intersecting objects is marked as climbable and the grip trigger is active then turn off the player gravity Move the position of the player based on how far the hands move up/down/left/right/forward/backwards that should move the player based on how you are moving the hands, this movement will be shaky as the position updates often so I would look to smooth that movement value out. When the player releases the grip turn gravity back on (only if the other hand isn't connected to a climbable object)
Some extra things to consider here
If the player currently has both hands attached to a climbable object you will want to limit the motion so the player can't move in weird ways, maybe a limit on the distance allowed between the two hand
You will need to allow in your script if it is a left or right hand so you can base your calculations off the correct controller.
If the player is only holding on with one hand, you probably don't want to let them extend out from the wall too far before loosing grip
Similarly if they player tries to move into the wall you will want to stop them
When the grip is applied, if you are using the avatar you will want to hide the hand so it doesn't move when the player is gripping/climbing
Add some stamina decrease while only holding on with one hand, if the stamina depletes remove the grip
If the player lets go with one hand and the other hand is far to one side, you may want to swing the player slightly closer to the gripping hand
For the climbable objects Add a collider Give the object a tag like "Climbable" (use that to detect if the item to players hands is intersecting with is a climbable object
For the head You'll want something that fades out the view if the players head intersects the climbing wall other wise they will be able to go through the wall Add a collider and do a similar check on the hands if the head intersects the collider of the wall then fade in/out a plane/quad in front of the camera to let the player know to move their head back
I would test- using collission instead of tiggers and set up the physics collision matrix for the hands/head/climbable objects, that may be more performant than a comparetag, however its unlikely you will have so many collisions and compare tags that it would kill the performance, but if you are targeting the quest you will want to limit the overhead as much as possible.
Hope that gets you started at least Its a reasonably difficult task to setup a good climbing script but pretty easy to setup a simple one that you can then expand on, best of luck