- Home /
Why my sphere fly away?
Hi, i'm new in this and i saw the tutorial video of: Roll-a-ball, i start yesterday. Now, my problem is when i put the script on the GameObject Sphere, the sphere fly away. It's a rigidbody and have check "use gravity" . But doesn't work.
Here the script:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour{
void Start (){
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0x0f, moveVertical);
rigidbody.AddForce (movement);
}
}
I tried add mass to the Sphere with "rigidbody.mass 0x05" or something like that.. But no, doesn't work again.
Thanks.
Where is y axis of your object (green axis in local coords)?
Nose$$anonymous$$ills, i'm using the same words on the tutorial vídeo... I'm really new on this.. I like program$$anonymous$$g, but i'm new. Your comment work, the sphere don't fly. But just moves on the X axis, i can't use "UP ARROW" or "DOWN ARROW"...
giulio, if you mean on Transform tab, Y coords are on 0.5, just over the plane.
But i can't move it with freedom.
I don't know what tutorial video you're following, but I would be very surprised if it said 0x0f as a parameter to a Vector3 constructor.
yeah @tanoshimi. That 0x0f almost sounds like a program$$anonymous$$g trick question you would pull on your colleague. Very misleading and unnecessary
$$anonymous$$arcos pls click the tick mark next to the answer to accept it as the correct one if it worked.
Answer by NoseKills · Mar 02, 2015 at 08:27 PM
Have you tried without adding the y force of 0x0f
?
Vector3 movement = new Vector3 (moveHorizontal, 0x0f, moveVertical);
"f" in hex is 15 in decimal, not "0x0 float". And why are you writing integers/floats as hex anyways?
Your answer
Follow this Question
Related Questions
Making a bubble level (not a game but work tool) 1 Answer
RigidBody immediately stops after AddForce 1 Answer
Problem with moving / jumping 1 Answer
Unity Physics On Input Issue? 0 Answers