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 Jussumman · Jun 30, 2016 at 11:59 PM · rotationrotation axiscapsule collider

How to add rotation to player collider within floppy bird type gameplay?

As part of learning unity I made a simple game in which the player flips a bottle cap that rotates and travels across the scene with random bottles as obstacles to avoid.

Here is a gif of gameplay: https://gfycat.com/EveryRegalGecko

The problem I encountered is the main player game object's Capsule Collider that matches the sprite image (bottle cap dimensions) can't be used with my code without destroying the game mechanics of flipping it straight up. Instead when the player taps the screen the capsule will go in the direction it's facing (constantly changing with the rotation so hard to play).

I found a solution to make it work by creating a sphere as the collider and placing it so it generally covers most of the player sprite (bottle cap), and not apply rotation (only to the sprite). This allows for the player to be flipped up regardless of orientation but it's not accurate as some extra space on top and bottom is added that will result in a collision that's not realistic. I had to redo the colliders on the obstacles (bottles) to make it appear realistic.

Here is a screenshot of the two colliders, the sphere is the one I resort to in order for it to work, the rectangular collider is the one I would like to use. alt texthttp://imgur.com/UxsJ9Jg

Here is the main code I use to make the player object "flip". It goes straight up (if I'm using a sphere as collider) and it will go relative to up direction of object if I use the rectangular collider. I also have some screenshots of the inspector I'm using here. http://imgur.com/a/gcH2a

 public Transform shotSpawn;

 private float nextFire;
 private bool gameOver;
 private bool fuelFire;

 void Update() 
 {    
     {
         transform.Rotate(new Vector3(rotationX, rotationY, rotationZ) * Time.deltaTime);
     }    
     
     if (fuelFire == true && Time.time * 1.0f > nextFire)
     {
         GetComponent<Rigidbody>().velocity = transform.up * speed;
         nextFire = Time.time + fireRate;
         Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
         fuelFire = false;
     }    
 }

Thanks for any advice or direction to make the game mechanics better.

capturecapsule.jpg (15.0 kB)
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

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

68 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 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 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

How to rotate an object relative to another different object's axies? 0 Answers

Make GameObject rotate around another around random axis but with fixed distance 0 Answers

How would I add rotation limits to this? 1 Answer

How can I flip a player over the Horizontal and Vertical axis? 0 Answers

Get object's rotation around axis defined by vector 2 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