I need to use both
GetComponent<ConstantForce> ().force = new Vector3 (Input.GetAxis ("Mouse X") * speed , 0f, Input.GetAxis ("Mouse Y") * speed);
GetComponent<ConstantForce> ().force = Vector3.MoveTowards( transform.position*2, transform.position*2, Time.deltaTime*2);
At the same time. Is it possible? I need player to both control object with ConstantForce and to have MoveTowards away from zero - at the same time…
Currently the last ConstantForce always works, while the first not
Vector3 values can be added together.
Vector3 first = new Vector3 (Input.GetAxis ("Mouse X") * speed , 0f, Input.GetAxis ("Mouse Y") * speed);
Vector3 second = Vector3.MoveTowards( transform.position*2, transform.position*2, Time.deltaTime*2);
GetComponent<ConstantForce> ().force = first + second;
Edit: That said, you could probably stand to use a much simpler approach, anyway.
GetComponent<ConstantForce>().force = Vector3.MoveTowards( transform.position*2, transform.position*2, Time.deltaTime*2);
GetComponent<Rigidbody>().AddForce(new Vector3 (Input.GetAxis ("Mouse X") * speed , 0f, Input.GetAxis ("Mouse Y") * speed));