- Home /
Movement Script for Player...
I need a movement script for my player which is a sphere. I found couple on the internet but they don't do what I want them to do. Some does, but they have so much code that I don't need.
Here is what I need in this movement script:
I need the player to be able to move in the x direction time.deltatime and on the z direction it should be able to move 2 unity units a time. I'm looking for the effect in little big planet.
I need the character to be able to jump, however it shouldn't do double jump. But it should be able to move while in the air.
The most important and hardest one is I need momentum on the sphere. What I mean by this is, I need the effect created by the bouncy physics material, the problem is this is not usable with the character controller. If you can get movement done without character controller, you could use sphere collider.
I need the camera to follow the player in the y and the x direction only!
Thanks... I really need some help!
If you would take some time to at least try to make a working script and post it on here I would be glad to help you. Please don't come here and ask for all of us to do all the work.
Nobody is going to write scripts for you here. If you don't want to do it yourself you can pay someone to do it for you in the Commercial Work section on the Unity forums
Answer by Cool Dave · Aug 24, 2012 at 04:40 PM
I've never seen Little Big Planet, but I'm guessing it's a ball rolling along the x which you control by sliding it on the z axis and jumping over obstacles.
Momentum has nothing to do with bounciness. I don't think you want to use character controller, however. Do you know much javascript? If you don't...
Let me shoot straight for a minute. You will never get anything done in Unity without knowing how to write the code. You can't use the already-made ones for everything. Javascript is really easy to learn, and you will become more productive quite quickly. I finally decided to learn, and I'm really glad I did.
For your script, attach a rigidbody to a sphere. Then using something like 'rigidbody.AddTorque (10,0,0);' you can give torque to the ball. To jump you need 'var makeBallJump : boolean = Input.GetButton ("Fire1");'
Attach this script to the ball to get started.
function FixedUpdate ()
{
//Be sure to set your fire1 key assignment in Edit>Project Settings>Input
var makeBallJump : boolean = Input.GetButton ("Fire1");
//This makes the ball go up
if (makeBallJump == true)
{
rigidbody.AddForce (0,40,0);
}
//This rolls the ball along
rigidbody.AddTorque (10,0,0);
}
Please mark this answer as correct, assuming it's helpful. Welcome to Answers!
I'm currently outside. I will be at home in 30 $$anonymous$$s I will post the script. I didn't post it because I thought It wouldn't have any use. And I changed $$anonymous$$d $$anonymous$$d about the question I will post it soon as I got home sorry thanks for trying to help.
Your answer
Follow this Question
Related Questions
Momentum locking jump 0 Answers
How do you calculate DeltaX and DeltaZ for a character? 1 Answer
Update() vs. FixedUpdate() for object rotation 2 Answers