Hi all
The following is a simple description of the setup:
- Player object is fixed at center of screen, at position 0,0,0.
- Huge see-through plane covers the entire screen area.
When the player clicks somewhere on the plane I get the coordinates from a simple raycast from camera. I then instantiate an object at the location of the player. The object then moves towards where the player clicked by having the following in its update function;
rigidbody.position += direction * (Time.deltaTime * speed);
The direction in this case is simply the location where the player clicked. Now it kind of works, but the catch is that the further I click away from the player, the higher the values of Vector3, meaning the faster the object will go. This is now what I want. Instead, what I want is to only use the direction from Player to MouseClick, and then send the object flying in that direction with a given speed I can control in a variable.
As for the object itself;
- Rigidbody set as kinematic
- Collider set to trigger
- Need to interact with other objects using either OnTriggerEnter or OnCollisionEnter
If there are any details I’ve forgot feel free to ask away. Thank you for your time reading this, and if you have a suggestion please feel free to share it