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 MikeErty · Nov 07, 2013 at 10:07 AM · dashspinboostcharge

Creating a sonic-style charged spin

I wanted to post this in the forum as it seemed a more general query rather than an issue that needed a definite answer but I couldn't find a relevant area to post it.

I have a game where the player controls a rolling ball with a joystick. The rolling is controlled by applying force to the ball in a direction matching that of the joystick. I have a button that, when held, begins the 'spinning' action.

The spinning action is intended to pin the object in it's current position and spin him round quickly to give the impression that he's 'charging up.' Upon release of the button he launches forward with a boost.

It works, sort of.

The only problem really is that despite the function setting his velocity to 0,0,0 he still slides slightly as he spins. He slides enough to make it obvious he's not stationary anyway. This is a problem because the whole point of this mechanic is to allow for accurate dashes, effectively pausing movement, allowing the player to aim with the joystick and then dashing in the desired direction.

I think the complication comes from the joystick applying force to the ball in a direction that allows the ball to be 'pointed' whilst also applying torque to make it spin.

My question is - given the setup of my game mechanics (rigidbody.addForce driving the ball movement) is this a good way to go about this or a terrible one doomed to fail? Is there a way to make what I have work or is there a more efficient, reliable way to do it?

Thanks for reading :)

Comment
Add comment · Show 4
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 meat5000 ♦ · Nov 07, 2013 at 10:30 AM 1
Share

In your situation I'd be tempted to use parent and child objects for your ball. Parent handles Directional/positional movement while child would handle spin/torque. This setup would mean the ball could spin but as the direction is maintained by the parent it always overrides the direction of the ball despite which way it is facing due to spin.

With this method you can use AddTorque for the spin.

avatar image MikeErty · Nov 07, 2013 at 10:38 AM 0
Share

interesting idea. I will impliment and experiment with this as soon as i've figured out why my objects have stopped exploding. If it's not one thing it's another lol!

avatar image meat5000 ♦ · Nov 07, 2013 at 11:10 AM 1
Share

With the method I describe, the child object controls the 'animation' of the ball but not the direction of movement. You can simply align the child object to the forward direction of the parent at the end of the spin. Of course the forward direction of the parent is controlled directly by the joystick.

Ins$$anonymous$$d of freeze position you can simply zero velocity and angular velocity.

avatar image MikeErty · Nov 07, 2013 at 02:49 PM 0
Share

thanks for the ideas guys I'll be sure to test them both out just as soon as I can and report back with my results :)

1 Reply

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

Answer by thef1chesser · Nov 07, 2013 at 10:51 AM

Another suggestion might be to set the rigidbody constraints

when spin
sonic.rigidbody.constraints = RigidbodyConstraints.FreezePosition;

to release sonic.rigidbody.constraints = RigidbodyConstraints.None;

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 MikeErty · Nov 07, 2013 at 03:00 PM 0
Share

I got a very good result with thef1chesser's suggestion of using

rigidbody.constraints = RigidbodyConstraints.FreezePosition;

to freeze position and then the opposite to unfreeze it!

However I do see the benefit of meat5000's suggestion which I will still try when I have more time (chesser's suggestion was implemented in about a $$anonymous$$ute).

Thank you very much :)

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

17 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

Related Questions

Forcing a rotation point 2 Answers

How do I stop a rigidbody from rotating after colliding with another object? 1 Answer

Charging up the speed of an game object through a mouse click 3 Answers

need help with a boost effect 2 Answers

Making an effective Airdash 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