Setting center of Character Control getting weird result

I am sure this is something I am not doing properly but hoping someone can shed some light on it.

Essentially I am adding a CharacterController via script and setting the center property. When I do this, it is actually offsetting the position of the GO I am attaching the controller to. The code looks like this:

var goControl : CharacterController = gameObject.AddComponent(CharacterController);
goControl.height = 10;
goControl.radius = 3;
goControl.center = Vector(0,5,0);

With that Vector set for the center, it causes the GO position to move -5 on it’s Y. Now, if I do the same thing (attach the CharacterController via script) but in the GUI set the center Y to 5 it works as expected and only moves the CharacterController and leaves the GO position.

Thanks for the help!

– Clint

Instead of creating the object from scripting, why not just instantiate a prefab?

I guess from your handle you come from the Director, and can see from your previous posts you have an affinity to create gameobjects from code.

May I recommend you try to get used to the Unity way of doing things: Create a fully configured game object, stuff it in a prefab, then call Instantiate on it to create your copy? Try it - its really nice - especially when it comes to tweaking your stuff…

Hiya,

I have and do use Instantiate quite a bit but haven’t messed with creating Prefabs all that much if at all. I certainly see the value in them though and will look more into them! Thanks for that…

As far as the issue I was mentioning… Is this a bug then?

Thanks,

– Clint

Okay,

So I just created one and it was less the painless. :wink: I may like using these…

Regards,

– Clint