Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ragnaros100 · Sep 11, 2014 at 02:11 PM · movementvelocitycharacter controllergameplay

How do I disable the Character controller but keep velocity?

I'm trying to figure out some sort of way make my player able to phase through walls, but keeping the velocity whilst doing so. Untill now I've made a trigger next to the wall and when the player walks into it, his character controller just gets disabled, but then he looses his momentum, which he needs to get through the wall and is just stuck there... Is there any way to do this with the character controller, or am I going to need to use something else?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by HarshadK · Sep 11, 2014 at 02:16 PM

  • Before you disable the character controller store the current velocity in a variable.

  • Then you can assign this velocity stored to you player to move him.

  • Once he has passed through the wall you can re-enable your character controller.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ragnaros100 · Sep 11, 2014 at 03:28 PM 0
Share

Thanks. This worked perfectly :)

avatar image
0

Answer by Ben-Stoneman · Sep 11, 2014 at 02:21 PM

As disabling the CharacterControllerScript causes the player to loose momentum, you will need to avoid doing this. If you don't want the player to be able to contol the character, simply put a feature in that stops the player from effecting the player, like an if statement.

 if(phasing = true)
 {
   //Effect when player inputs
 }
 else //No effect when player inputs

If the player effects the momentum, then you will need to freeze the velocity until phasing is complete.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Owen-Reynolds · Sep 11, 2014 at 02:28 PM

Not really. When you use a character controller script, you don't have a velocity, in the sense of a rigidbody. The code in the character controller script (which ever one you use) does the movement, based on some of it's variables. Disabled script means disabled movement. It's like asking for a television to keep the last image after you unplug it. Only way to "keep" the velocity is to have someone else read and use those variables.

But I wouldn't bother trying to capture the velocity. What if they very slowly hit the wall. It takes them 30 seconds to slowly phase through? And if they sprint up to the wall, I think it still looks good they have to slow down into "wall phasing speed."

I'd just have them hit the trigger (and maybe they have to press the phaseWall button?) and always go through the wall at a set speed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Accurate and timely velocity-based movement 0 Answers

Movement using rigidbody.velocity to apply a constant force until stop 1 Answer

Player slows down when jumping/velocity changes 1 Answer

Character won't move (Fixed) 1 Answer

Space Shooter Tutorial Player Won't move. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges