Hi there,
I’m a bit of a Unity3D novice and could really use some pointers on a game that I’m building. It is a simple FPS game with one weapon: a really big rocket launcher. The character controller has within it a gun object that instantiates a rocket on left mouse click, and the rocket prefab has Constant Force on it so it flies forward. What I want to do is make it to on right mouse click, a rocket is instantiated and the player object is attached to it, with the FPS controls inactive. The point being that if the player clicks alternate-fire, they are able to ride on a rocket. Steering the rocket is done by moving the mouse. The player can jump off at any time and fall to the terrain, while the rocket continues on its trajectory.
So far, I’ve made it so when the game starts, a prefab (named Player) with the FPS controller in it is instantiated. Player has a Gun object (in the Mouselook) which has the script that instantiates rockets on mouse clicks, per the old Unity FPS tutorial. Movement controls and shooting rockets works fine. Just for kicks, I’ve also made a separate object with a capsule, camera, and mouselook on a Rocket object, with the mouse steering working. However, I don’t think the “walking” player and the “flying” player modes should be separate objects. Rather, it seems to me like the logical way would be to have the Player prefab instance always remain, no matter if it was walking around with the FPS controls or sitting on a Rocket.
So, my main question is: How do I make the Player object physically attach itself to an instantiated Rocket object? I’m assuming I would update the Player’s position with the Rocket’s, but how do I refer back to the Player object from the script in the Rocket object?
Also: How do I disable the FPS controller (so they can’t move with the arrow keys or jump) when a Player is riding on a Rocket?
Finally: How would I make the Player object’s mouselook change the direction of the instantiated Rocket when the player is flying?
My apologies for loading this request with a lot of questions, and my general newbishness. I would genuinely appreciate any insight you guys could give me into these seemingly simple problems.
Thank you!
P.S. I originally posted this in the Unity Forums before I realized this might be a better place for it. Sorry for the cross-post!