Search Unity

Inverting gravity/CharacterController problems

Discussion in 'Physics' started by Deleted User, Dec 22, 2017.

  1. Deleted User

    Deleted User

    Guest

    Hi,

    I'm trying to invert ingame gravity to make my character walk on the ceiling for example, i've done some searches and find quit a few threads talking about this but none of them helped me fixing my problems.
    I'm even considering ditching the default unity character controller to make my own.

    I have a script inverting Physics.gravity on mouse click.

    First I can't get the character controller to rotate. Trying to rotate it in the editor or with a script don't work as the character is always facing upward.

    Second I can't get the character grounded (to make it jump for example), I tried accessing the FirstPersonController component to change some variables but I get an error, as I asked in this question.

    Also after switching gravity my character doesn't immediately fly upward, it will stick to the ground until I jump. I have an idea on how to fix this but as I said above I can't access FirstPersonController variables.

    I would be awesome if someone could help me out, thanks.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I looked at your other question and it's odd if that's how it is that you can't access the variable.
    However, on another note, I believe you cannot rotate the character controller at all. Its rotation is fixed...
    You'd have to try changing to a rigidbody character controller, I think. There's one in the standard assets you could try your game theory/physics with, perhaps.
    Hope that helps..
     
  3. Deleted User

    Deleted User

    Guest

    Indeed it's weird how I can't access the variables, I think my project is corrupted so if I can't find a solution i might remake another project.

    And i'm using the default unity character controller, and It have a rigidbody
     
  4. Deleted User

    Deleted User

    Guest

    I also have this warning with the error :

    Code (CSharp):
    1. Assets/Script/SwitchGravity.cs(16,16): warning CS0436: The type `UnityStandardAssets.Characters.FirstPerson.FirstPersonController' conflicts with the imported type of same name'. Ignoring the imported type definition
     
  5. Deleted User

    Deleted User

    Guest

  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Looks like you tried to make a type that was already imported (judging by the message). Did you try a new project , yet at all?
     
  7. Deleted User

    Deleted User

    Guest

    It works in a new project, but i'd like to figure out how to fix it in my current one
     
  8. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Well, perhaps on that line in the error you posted, you have declared a type that is the same. Try removing that declaration and see if it works.