x


Make rigidbody walk like character controller

I am using a rigidbody to model my character. I have to use it because I need full physics. But the problem is that it accelerates/decelerates when moving. Is there a way to avoid this, so it has constant velocity?

more ▼

asked Dec 05 '09 at 02:55 AM

Ricardo Arango gravatar image

Ricardo Arango
628 10 13 26

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

You might want to take a look at the RigidbodyFPSWalker script on the Unity Wiki.

more ▼

answered Dec 23 '09 at 10:23 PM

rocket5tim gravatar image

rocket5tim
859 12 17 33

Tried the project on this wiki. Unity had to rebuild it as it was made on a higher version than my 2.6. Seems to work, partially. FPSWalker does not stop moving after a certain amount of 'walking' it... and the direction keyboard keys no longer match the direction the FPS takes on... FPS rapidly falls off the platform to infinity. Will make platform huge to see if I can get a feel for the behavior of the FPS.

Jul 11 '10 at 02:26 PM dingben

Was losing the capsule(FPS) in the hierarchy? ...renamed all the cubes 00,01,02,... 10. When hit 'play' the capsule becomes child to cube10(non-terrain-floor)... while using arrow keys to move around, the FPS changes shape and also builds up large speed in any one direction that cannot be compensated by the arrows action... and poof we go to infinity. Don't know if it is due to Unity (versions)conversion or bad C# script... I use javascript, can't comment further until I have had a chance to translate the C# to javascript

Jul 11 '10 at 04:47 PM dingben
(comments are locked)
10|3000 characters needed characters left

directly controling Velocity ;)

var speed:float=4;
function FixedUpdate(){
    rigidbody.velocity=(Input.GetAxis("Horizontal")*transform.right+Input.GetAxis("Vertical")*transform.forward).normalized*speed;
}
more ▼

answered Aug 28 '11 at 07:50 PM

Techsuport gravatar image

Techsuport
81 6 6 10

(comments are locked)
10|3000 characters needed characters left

It may not be the Character Controller see

http://forum.unity3d.com/viewtopic.php?t=39946

more ▼

answered Dec 23 '09 at 08:14 AM

bill gravatar image

bill
41 1 1 4

(comments are locked)
10|3000 characters needed characters left

you can have constant velocity by disabling friction and drag and setting the velocity of the rigidbody directly to a value. you should not aply forces and you should just use the velocity property and set it to the value that you want. generally it's not a good idea to make your character move in this way. you should use ragdolls when you need physics and use character controllers when you don't need it. simulating human movements with physics is not an easy task and it will become very heavy. there is a great video about physics in unite 08. one of the problem that is described there is "character simulation using ragdolls or rigidbodies".

hope this helps

more ▼

answered Dec 05 '09 at 03:57 AM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1865
x1783
x1040

asked: Dec 05 '09 at 02:55 AM

Seen: 14883 times

Last Updated: Aug 28 '11 at 07:50 PM