Reputation: 313
I started tutorial https://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player and I don't understand why, after clicking Play, Position Y is automaticly, constantly changing value. I was following tutorial and I don't what I could miss. The efect is that my ball after clicking Play is disappearing immediately..
Maybe somebody had similar problem?
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}}
Upvotes: 0
Views: 51
Reputation: 435
The ball is falling down, it needs to land on another rigidbody that is not susceptible to gravity (gravity scale = 0)
Upvotes: 0
Reputation: 502
The Player object's y-coordinate is automatically changing means it's basically falling downward automatically.
Remember that gravity is enabled for rigid bodies automatically and maybe you haven't attached a rigidbody to the main floor play area.
Go over the tutorial again and follow along the steps carefully, especially checking if a rigidbody has been attached to the plane.
Upvotes: 1