Hi there guys, I’m not sure if it’s been asked here yet but here is my question :
I’ve got a project with a player character working fine… I have a 3d model of a horse that the player is animated for and could fit on as a rider.
How would one go about mounting the player on the horse (or if you had a car, or some other vehicle), and then making said horse controllable?
I’d imagine i have to just make a character controller for the horse, the same way i did for the actual character… and my guess would be… to set a variable like IsController = true or false when you approach the horse and enter a trigger, or hit the mount button (or both) so i could use that in the character controller’s update functions to disable which character controller is active… correct in thinking?
I understand that logic… BUT how i do actually physicly instantiate a character on another game object… and KEEP it there? I’d want to instantiate it on a game object that i place right on the horse’s back, or a car seat… and then play a sitting animation…
I’m unsure how to do that. Any help would be awesome! Thanks guys
Word to the wise: avoid instantiations when you don’t really need them. This is how I did it using my custom rigidbody-based character controller (untested psuedo-code):
var canMount:boolean = true;
//How to get on...
function Mount():IEnumerator{
if(canMount){
canMount = false;
transform.position = mountPos;
transform.parent = mountTransform;
if(rigidbody){
rigidbody.useGravity = false;
rigidbody.isKinematic = true;
}
//...
}
}
//...and how to get off
function UnMount(){
if(!canMount){
//Un-do all that other jazz
}
}
Really not to hard to do once you wrap your head around it
very cool man! definitely what i’m trying to do, i haven’t quite gotten it to work yet. hehe. care to help ? how did you set up the character controllers? swapping between them and turning them off and on again?
what i did was parent the horse to the character then put the same character controller i put on my character on the horse and called it horse controller then when the character mounts the horse i use the enable disable to turn the persons controller off and the horse controller on to mount the horse i use triggers