- Home /
Moveable Character Controller
Say I had a game where I have several models running around performing tasks under AI control, but I want to be able to slip into first person on any of the models. How do I go about "moving" the fps controller from one model to another?
Answer by HarshadK · Jul 17, 2014 at 10:17 AM
Character controllers are nothing but components.
So you can assign your character controller to your any game object using GameObject.AddComponent
And to remove your character controller component from your game object just use Object.Destroy
You just need to perform these operations on your intended game objects (models) i.e. AddComponent to your target game object and Destroy character controller from your previous game object on which it was present.
Be aware you will also need to disable/destroy whatever AI control there was on the model.
I can't vote you up for some reason, but that looks very promising...thanks.
You need to have at least 15 karma to be able to vote up. But that's alright. Happy to help. :-)
So after going back and re-engineering I can say that was absolutely the right answer. It works, and works well. Fixed all my crappy work arounds and I'm back on the right track! Thanks again!
One question though, is it better to destroy the object or just disable since the player could re possess any creature? Any memory/speed concerns to those approaches?
Your answer
Follow this Question
Related Questions
Problem with the standard mouselook script 0 Answers
Issues with camera and player rotation scripts for basic FPS controller. 2 Answers
How can I add smooth movement to a RigidBody? 2 Answers
Hit detection with unity character controler 0 Answers
Mouselook Is rotating Z-Axis of Camera Unexpectedly 1 Answer