- Home /
How to implement sonic style Rolling/Spindash,How would I implement a rolling feature for the player in unity?
I'm a fairly new to unity, but I'm trying to learn more about the program. To this end, I'm attempting to create a sonic clone, but I'm really stumped on the rolling mechanic. The only way I know how to implement something like this is to make it so the player changes from a box collider to a circle collider, but I don't know if that's even possible. I tried to look up some tutorials to see if I could find something on how to do it, but haven't found anything. So I thought I'd make a post here to see if anyone could help. ,I'm somewhat new to unity, but in an attempt to expand my knowledge within the program I wanted to make a sonic clone. Something that's got me stumped is the spindash/rolling mechanic. I don't know how I would implement something like this within the game. The only way I can think to do it is to change the player's collider from a box collider to a circle collider, but I'm not sure how I would go about doing that, or if it's even possible. I tried looking up tutorials on how to do it, but haven't been able to find anything. I was hoping someone could help me here.
Answer by ZY_bros · 5 days ago
first add a box collider and a circle collider, disable the circle collider then use gameObject.GetComponent<>(BoxCollider).enabled = false and gameObject.GetComponent<>(CircleCollider).enabled = true on your player
it took me a bit, but I was able to figure out how to get it to work (the main struggle was wrestling with input system and figuring out how to add buttons with the input manager). The circle collider worked at first, but I noticed it was just... sliding down the halfpipe I made instead of rolling down. So I turned on rotation for the rigidbody, and that seemed to help, but not very much. I have a circle in the scene along with the player that rolls around the halfpipe for testing this mechanic, and the player moves very slowly down the halfpipe compared to the circle. Am I somehow missing something?
does the player also have a circle collider? also could you upload a video showing the problem
The player also has a circle collider, but it rolls much slower than I'd like, and I'm not sure how to make it go faster. The only thing I can think of is using apply force instead of velocity to move the player. Also I apologize for the extremely lackluster graphics. I wanted to get as much of the game working as possible before doing any pixel art. Here's a link to a video of what's going on: https://youtu.be/uz7e4RRQ_RI
Your answer
Follow this Question
Related Questions
Handling friction in scripts for a 2D platformer 1 Answer
Use 2D Effectors with Raycast Collision Method 0 Answers
Wall jump push force 1 Answer
How do I make it so only one player spawns when I respawn? 0 Answers
Shade Cloak in Unity 1 Answer