Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem with RigidBody and FPSWalker script?

Discussion in 'Editor & General Support' started by DaveyJJ, May 28, 2005.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    When I add the FPSWalker script to a sphere with a RigidBody component added, when you move the sphere it no longer rotates during movement. It remains "upright" and doesn't roll along either the X or Z axis.

    How would you make it still roll while under player/FPSWalker control?
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Not sure exactly, but I can till you one thing:

    The FPS walker script is not made for rolling marbles ;-) I will be working on it this weekend, making it more FPS-like. That means it will be even less marble-rolling ;-)

    Instead, try to write a small JavaScript that rolls the ball depending on player input. Take a look in the scripting examples folder in /Users/Sharede/Unity for some ideas...
     
  3. Krispy

    Krispy

    Joined:
    Jun 6, 2005
    Posts:
    69
    It's fairly simple actually.

    Change
    Code (csharp):
    1. rigidbody.AddRelativeForce (new Vector3 (x, 0, z), ForceMode.VelocityChange);
    To
    Code (csharp):
    1. rigidbody.AddForce (new Vector3 (x, 0, z), ForceMode.VelocityChange);
    and to get it rotating again, Change
    Code (csharp):
    1. rigidbody.freezeRotation = true;
    To
    Code (csharp):
    1. rigidbody.freezeRotation = false;
    Sit back and watch the rolling :)
     
  4. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Seriously? I'll try that in my tutorial and let you know! That's fantastic, Krispy!

    EDIT- Solved, thanks Krispy.
     
  5. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    A(nother) word of warning: don't expect the builtin FPS script to remain unchanged. I have a vastly superior script on my machine, which will probably be included in 1.0.1...

    Feel free to play around, but don't count on being able to do this IN the turtorial for very long ;-)
     
  6. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    OK!