Hi guys,
i have a little problem with my Unity Script, that is writting in CSharp:
using UnityEngine;
using System.Collections;
public class Kegel : MonoBehaviour {
public Vector3 startposition;
// Use this for initialization
void Start () {
startposition = transform.position ;
}
// Update is called once per frame
void Update () {
if(transform.position.y <= -10 )
transform.position = startposition;
rigidbody.angularVelocity = Vector3.zero;
rigidbody.velocity = Vector3.zero;
return;
if(Input.GetKey(KeyCode.W ) )
rigidbody.AddTorque(20*Time.deltaTime,0,0);
if(Input.GetKey(KeyCode.S))
rigidbody.AddTorque(-20*Time.deltaTime,0,0);
if(Input.GetKey(KeyCode.A))
rigidbody.AddTorque(0,0,20*Time.deltaTime);
if(Input.GetKey(KeyCode.D))
rigidbody.AddTorque(0,0,-20*Time.deltaTime);
if(Input.GetKeyDown(KeyCode.Space))
rigidbody.AddForce (0,250,0);
}
}
i want the sphere to go to the startposition but the problem is the following part:
}
// Update is called once per frame
void Update () {
if(transform.position.y <= -10 )
transform.position = startposition;
rigidbody.angularVelocity = Vector3.zero;
rigidbody.velocity = Vector3.zero;
return;
if I implement that, the sphere will no longer move. just down because of the physics but you can no longer influence the direction.
I have no clue, what the problem could be. I am just a beginner.