Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Rotating a Character With FixedAngle

Discussion in '2D' started by iEpic, Jun 18, 2014.

  1. iEpic

    iEpic

    Joined:
    Sep 29, 2013
    Posts:
    119
    I've been stuck on this the last few days so I'm hoping you guys can help.

    I'm making a 2D game and I want my character to slip, fall backwards, and hit his head when he tries to run on ice for too long. My goal is to have it where if you keep holding the run button long enough on ice, he will slip backwards and damage himself. I'm using playmaker but I do know a little c# programming.

    The first thing I tried was making an animated float that adds the rotation to the Z axis over time, but that went horribly wrong and makes the character jump/skip/glitch all over the place.

    The second thing I thought of was to add 2D torque to make him start slipping backwards, but he stays in the same rotation with fixedAngle true.

    So then I made it where fixedAngle is false when he is on ice, but he immediately falls forward or backwards as soon as I start running. I made the center of mass right in the middle so he stands fine as long as he is not moving.

    Does anybody know a way of achieving the effect I want? This is my first game and I am a noob, so hopefully there is an easier/correct way of going about this. I could be doing this all wrong, so any guide in the right direction would be greatly appreciated.
     
  2. Rutenis

    Rutenis

    Joined:
    Aug 7, 2013
    Posts:
    297

    Well, what i would suggest you to do is use WaitForSeconds statment. If youre pressing any button, check the bool to be true. While the bool is true, wait for your wanted amount of seconds and if the bool is true for too long, damage your player. If you want me to show example, say it.
     
  3. peterdeghaim

    peterdeghaim

    Joined:
    Apr 10, 2014
    Posts:
    154
    Have you tried using animations?
     
  4. iEpic

    iEpic

    Joined:
    Sep 29, 2013
    Posts:
    119
    OMG I never even thought of that. Make a falling backwards animation play, when he starts slipping instead of actually adding torque and messing with the fixedangle.
    Genious!
    I'ma try it now and tell you how it works. I can't believe I never thought of that and literally spent at least like 20 hours trying to get this to work.
     
    peterdeghaim likes this.
  5. peterdeghaim

    peterdeghaim

    Joined:
    Apr 10, 2014
    Posts:
    154
    haha! dont beat yourself over it too much, i once spent weeks wondering why physics werent working on objects i had set to kinematic lol