- Home /
Move until collision sticks
Hi there. I searched on the forum and saw many questions regarding this issue, however I wasn't able to fix my problem or find a particular solution for it. I found a way for it to work but it's not optimized and I think it's too complicated for what it should be.
First of, I am making a game in which there's 2 players. One of them has 30 seconds to chase the other one. If he succeds, he scores a point, if he fails, the roles switchs. Once you have made a movement, you cannot move again (very important). My game is in 2D view (I scripted in 3D but I'm going to switch everything in 2D). Here's a look at the prototype.
To download the build (use the "test" scene) : https://mega.co.nz/#!tZ8kySpR!xt_OMFpnHASx9U_AGitcch5yB23gCZ6liqRp9gwMlg4
For this version, there's a rigidbody on both players and my script detects the Axis used to move it towards a direction. It adds velocity in a direction but before I check if the magnitude is 0 (so it only moves when the object is stopped).
The thing is, its kinda sticks to the wall and the response time before making another move is too long. It breaks the gameplay and I would like it to be faster, more reactive. What I liked about using that, is that I could collide with 2 walls at the same time and still be able to move.
I tried putting blocks for triggers and move the object until it collides with the trigger, but I didn't find a way to still move if it was colliding with another wall (corners were a real pain).
Do you guys have a suggestion that could be implemented or more optimized? I had the idea to use Raycast but I'm not really familiar with those and didn't want to invest time in that since it was "working" with the velocity.
I have the impression it should be easier. Would it be if I switch to 2D? At start I though I could only uses translates (translate left until collision) but I found out it wasn't as easy at it seemed. Our big inspiration is Toto Temple gameplay video, if the movements could be similar but without the gravity, it would be perfect.
Thanks in advance for your help!
Your answer
Follow this Question
Related Questions
Rigidbody magnitude comparison is not working correctlly? 2 Answers
Unity3D: Get Velocity after collision 0 Answers
Multiple Cars not working 1 Answer