- Home /
Inherit character controller velocity or movement?
Hi,
I'm using the FPScontroller and character controller scripts on my player, I've added some code to give a jetpack type function which works ok but how can I inherit the player movement while jetpack is on? Eg. maybe get the character controller velocity and use that? I think it is working but maybe the controls need to be exaggerated, can anyone give any tips on this?
Hopefully I'm explaining myself ok?
How about a bool? I guess you're activating the Jet pack via button press or something
bool jetPackActive;
void Update(){
//Jet Pack Control Start
if (jetPackActive) {
//Do JetPack Control
}
//Jet Pack Control End
//Character Control Start
if (!jetPackActive) {
//Do Character Control
}
//Character Control End
}
Hi, thanks for your ideas! $$anonymous$$y jetpack code is in a seperate script , not sure if you ideas might work, I'll try it out, but how to keep the movement or transfer it between scripts?
If the jetpack has $$anonymous$$ovement control too you can still use a bool in Jetpack.cs and pass it to the char control script then at the very beginning in the Update
void Update(){
if (jetPackActive) {
return;
}
}
If the jetpack has NO $$anonymous$$ovement control and your character has rigidbody you can use the Rigidbody velocity in the JetPack script.
But it depends which character controller you're using. It would be nice to see some script.
Answer by khos85 · Sep 12, 2015 at 06:31 PM
Was able to get this working by using code:
transform.position += transform.forward Time.deltaTime movementSpeed
Your answer
![](https://koobas.hobune.stream/wayback/20220612033256im_/https://answers.unity.com/themes/thub/images/avi.jpg)