- Home /
2D Platformer queries
I got excellent help in my last question so I decided to throw two more questions up in hope for a similar reaction!
How would I go about making it so certain surfaces cause a loss of friction, (example a slippery surface which makes it difficult for the player to direct themself, but not a total loss of control)
How would I make a gravity lift type mechanic? Like the player walks into say a wind turbine pointing upwards and it pushes the player upwards to a different point of the map?
Is there any way to do this, like a script I can input, or an easy explanation? I'm quite new to unity. All help is appreciated :)
Answer by Cowsmanaut · Mar 05, 2014 at 08:55 AM
There is a physics material2D which you can import by right click in your assets and Create> this can then bet dragged to any collision object to allow you to assign a friction and a bounce factor to collision objects. I've managed to make the bounce work just fine, but the friction appears to do nothing. Might be me, or might be a bug.
for the hover, there is a tutorial in the learning area for this as a 3D thing, but you need only change the elements to the 2D variants of the same commands..
public Vector2 hoverForce;
void OnTriggerEnter2D (Collider2D other)
{
other.rigidbody2D.velocity = (hoverForce * Time.deltaTime);
}
edit: I continued to play with this, and discovered the issue with the friction is that the 2D friction will not work if you're using rigidbody2D.velocity, but will work if you use rigidbody2D.addForce. The difference between the two, is that the addForce will gradually build as you move, where as the velocity is more immediate.. So, if you want to use both, my suggestion is to make an exception to your character that when they are touching a slippery surface, move with addForce and when not, use velocity. :) seems to be working for me.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity 2D player sticks on platform corners 2 Answers
jittery collisions 2d platformer 1 Answer
Help with a 2d camera Controller 1 Answer