x


Switching between FPS and Relative during play?

Is there a way I can have two controllers for the same Player, but use them at different times?

I want to use the First Person Controllers (prefab for iPhone) during some parts of the gameplay, and then switch to the Player Relative Controls during other parts.

My tries and searches have come up with nothing yet though, so I thought Id ask as well.

more ▼

asked Mar 22 '10 at 11:23 PM

Daniel 1 gravatar image

Daniel 1
31 8 8 11

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Sure, have both control scripts attached to the player, and disable the first person control script when needed and enable the player relative control script instead. And vice versa. Assuming the fp script was called FirstPersonControl and you're doing it from another script:

(GetComponent(FirstPersonControl) as FirstPersonControl).enabled = false;

If you're doing it from within the script, you just need

this.enabled = false;  // or true, depending

Also, as an aside, most functions in disabled scripts can still be accessed. Disabling scripts primarily just disables Update and OnGUI functions and not many others.

more ▼

answered Mar 23 '10 at 12:58 AM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5268
x2013
x548
x186

asked: Mar 22 '10 at 11:23 PM

Seen: 1478 times

Last Updated: Mar 22 '10 at 11:23 PM