I tried both the ways but its not working
I am using unity 2019.6.0a3
GVR-1.200.1
public float speed = 4.5f;
public float MovementAmplitude = 0.1f;
public float MovementFrequency = 2.25f;
public float JumpingForce = 450f;
// Start is called before the first frame update
void Start()
{
//transform.position = new Vector3(-3.21f, 3.833f, -38.004f);
}
// Update is called once per frame
void Update()
{
transform.position += speed * Vector3.forward * Time.deltaTime;
transform.position = new Vector3(
transform.position.x,
Mathf.Cos(transform.position.z * MovementFrequency)*MovementAmplitude,
transform.position.z
) ;
//GvrPointerInputModule.Pointer.TriggerDown ||
if (Input.GetKeyDown("space"))
{
Debug.Log("SPace is pressed");
Debug.Log(GetComponent());
//GetComponent().AddForce(Vector3.up * JumpingForce);
Rigidbody rb = GetComponent();
rb.AddForce(Vector3.up * JumpingForce);
}
}
↧