Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Lexxio · Nov 18, 2016 at 09:43 PM · 3dplatformerwallrun

How do I create a wallrun where the player is rotated so the wall becomes his new floor?

It's quite simple. When the player is walking against a wall, he will be rotated so the wall becomes his new floor. All that in a 3d world.

Something like this:

alt text

(The arrow is the player with the direction he is facing up(in his view) and the red thing is a object that makes it possible switch between the two walls(similar to the things in mario kart 8))

It would be awesome if someone could help me with that.

unbenannt.png (9.2 kB)
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 TBruce · Nov 18, 2016 at 10:05 PM 0
Share

The way I would proceed with this is to change the direction of gravity. You will need to create your own gravity functionality though.

To do this your player object still needs a Rigidbody, but you will need to turn off gravity since you will be manipulating it yourself using a ConstantForce component. The following code allows this

 public enum GravityType {NormalGravity, ReverseGravity, RightGravity, LeftGravity}
 
 public float gravityDown = -9.81f;
 public float gravityUp = 9.81f;
 public float gravityLeft = -9.81f;
 public float gravityRight = 9.81f;
 private ConstantForce myGravity;
 private Rigidbody rigidbody;
 
 void Start()
 {
     rigidbody = GetComponent<Rigidbody>();
     if (rigidbody == null)
     {
         rigidbody = gameObject.AddComponent<Rigidbody>(); // add a Rigidbody component
     }
     rigidbody.useGravity = false; // forget about physics default gravity
 
     myGravity = gameObject.GetComponent<ConstantForce>();
     if (myGravity == null)
     {
         myGravity = gameObject.AddComponent<ConstantForce>(); // add a ConstantForce component
     }
     SetGravity(GravityType.NormalGravity);
 }
 
 public void SetGravity(GravityType gravityType)
 {
     switch (gravityType)
     {
         case GravityType.NormalGravity:
             SetGravity(new Vector3(0, gravityDown, 0)); // set regular gravity
             break;
         case GravityType.ReverseGravity:
             SetGravity(new Vector3(0, gravityUp, 0)); // set regular gravity
             break;
         case GravityType.RightGravity:
             SetGravity(new Vector3(gravityRight, 0, 0)); // set regular gravity
             break;
         case GravityType.LeftGravity:
             SetGravity(new Vector3(gravityLeft, 0, 0)); // set regular gravity
             break;
         default:
             SetGravity(new Vector3(0, gravityDown, 0)); // set regular gravity
             break;
     }
 }
 
 public void SetGravity(Vector3 g)
 {
     // calculate the necessary force to produce the desired gravity:
     myGravity.force = g; 
 }

Here is a Unity package that demonstrates this (simple but I am sure you will get the gist of it) - you may need to play with the values to get your desired results.

This only shows you how to manipulate gravity. You will need to add the functionality to your controller and make the necessary granges to gravity as needed.

gravitytest.zip (11.1 kB)

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

3D side scroller following Sebastian Lague platformer controller 0 Answers

Simple water for 3D Platformer? 0 Answers

How to fix my wallrun 0 Answers

Mecanim platformer side view animation states approach 0 Answers

Third person platformer | Player can only jump while moving. Please help. 0 Answers


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