Hi. I’m doing space shooter game and I have one issue. When I’m flying into my planet(big sphere with sphere collider) for longer then one hit(my cube whitch represends my ship just bounce for a while on sphere) and i stop presing control button my ship flyes away from planet. I don’t know what to do and how i can prevent it. Any help? I’m attaching my scripts from planet and player.
Player(has collider and ridgitbody) :
using UnityEngine;
using System.Collections;
public class GraczS : MonoBehaviour {
public float speed= 10;
// Update is called once per frame
void Update () {
float front_w = Input.GetAxis("Vertical")* speed * Time.deltaTime;
transform.Translate(Vector3.forward * front_w);
float upanddown = Input.GetAxis("UpandDown") * speed * Time.deltaTime;
transform.Translate(Vector3.up * upanddown );
float side_w = Input.GetAxis("Horizontal")* speed * Time.deltaTime;
transform.Translate(Vector3.right * side_w);
}
}
And planet(Only collider)
using UnityEngine;
using System.Collections;
public class Ziemia : MonoBehaviour {
public float predkoscObrotu ;
// Update is called once per frame
void Update () {
transform.Rotate(Vector3.up * predkoscObrotu * Time.deltaTime);
}
}