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 ProXenT · Dec 03, 2012 at 07:32 AM · movement

Character pass trought wall...

Hello, i have a little problem, i know thats its not a big problem but i dont know how to repair it. my character pass trought wall with one script but not with the other.. with this script (The Good) i pass trought my wall :

 var speed = 13;
 var gravity = 20.0;
 
 private var moveDirection = Vector3.zero;
 private var grounded : boolean = false;
 
 function FixedUpdate() {
     if (grounded) {
 
 if (Input.GetKey("w") || Input.GetKey("s"))

     {
        transform.Translate(0, 0, Input.GetAxisRaw("Vertical") * Time.deltaTime * speed);   //Axe Z
     }
 
 if (Input.GetKey("a") || Input.GetKey("d"))
     {
        transform.Translate(Input.GetAxisRaw("Horizontal") * Time.deltaTime * speed, 0, 0);   //Axe X
     }
 
     }
 
     //Mettre la gravité
     moveDirection.y -= gravity * Time.deltaTime;
 
     // Bouger le joueur
     var controller : CharacterController = GetComponent(CharacterController);
     var flags = controller.Move(moveDirection * Time.deltaTime);
     grounded = (flags & CollisionFlags.CollidedBelow) != 0;
 }
 
 @script RequireComponent(CharacterController)

and with my older script he did not pass :

 var speed = 13;
 var jumpSpeed = 8.0;
 var gravity = 20.0;
 
 private var moveDirection = Vector3.zero;
 private var grounded : boolean = false;
 
 function FixedUpdate() {
     if (grounded) {
 
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
 
        if (Input.GetButton ("Jump")) {
          moveDirection.y = jumpSpeed;
        }
     }
 
     //Mettre la gravité
     moveDirection.y -= gravity * Time.deltaTime;
 
     // Bouger le joueur
     var controller : CharacterController = GetComponent(CharacterController);
     var flags = controller.Move(moveDirection * Time.deltaTime);
     grounded = (flags & CollisionFlags.CollidedBelow) != 0;
 }
 
 @script RequireComponent(CharacterController)

My wall have a mesh collider on it because it is a model 3D .. This one : http://www.fileserve.com/file/WthEprQ/level 1.FBX

Comment
Add comment · Show 1
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 ProXenT · Dec 03, 2012 at 05:22 AM 0
Share

For the HiperLink, Take all the last line ! sorry...

1 Reply

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

Answer by MountDoomTeam · Dec 03, 2012 at 09:24 AM

With one of the scripts, you are translating the player, so you are in effect pushing him,

With the other script, your changing his transform.position,

Transform.position override the physics it's as simple as that.

the scripts use different movement commands, one is relative to player the other is relative to world position. if you want to override the wall, you can turn off the wall collider if character wall distance smaller than 1.

Comment
Add comment · Show 6 · 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 ProXenT · Dec 03, 2012 at 12:43 PM 0
Share

and how can i write that iin my script ?

avatar image fafase · Dec 03, 2012 at 01:16 PM 0
Share

Use teh second script, the one that works. There is no use for a Character Controller is yuo do not use teh functions that go with it.

avatar image MountDoomTeam · Dec 05, 2012 at 05:12 PM 0
Share

http://answers.unity3d.com/questions/26844/enabledisable-specific-components.html for turn on off rigidbody, look for enable component unity on google

avatar image fafase · Dec 06, 2012 at 08:12 AM 0
Share

You should avoid having rigidbody and character controller on the same guy. You will see some weird behaviors as each kinda tries to overlap the features of the other.

avatar image MountDoomTeam · Dec 06, 2012 at 08:45 AM 0
Share

ya if you need to turn off a rigidbody, do that on the wall, otherwise player can fall through the floor.

Show more comments

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

11 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Set up a 3D fly through 4 Answers

TERA style movement 1 Answer

Simulating Marble Blast Gold: A script to make a character as a marble roll forward, mouse turns screen? 2 Answers

Need a help for movement Script! 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