- Home /
Question by
RealEfrain12 · Nov 24, 2020 at 02:15 AM ·
3dui imagecrosshairanchor
How to anchor Image UI's
For my game I'm making a crosshair, and I have an aiming script, I added a crosshair, but every time I aim the Ui also moves, I want it to just stay in the middle not move while also aiming. The code for aiming is in the answers.
Comment
Answer by RealEfrain12 · Nov 24, 2020 at 02:15 AM
void DetermineAim()
{
Vector3 target = normalLocalPosition;
if (Input.GetMouseButton(1)) target = aimingLocalPosition;
Vector3 desiredPosition = Vector3.Lerp(transform.localPosition, target, Time.deltaTime * aimSmoothing);
transform.localPosition = desiredPosition;
}
Your answer
Follow this Question
Related Questions
Best practice to display an icon 0 Answers
How to create HitCross on my gun`s sight when it hits the enemy. 1 Answer
Warp Image/Sprite Anchors? 1 Answer
How to have a 3D anchor point that limits how far you can go? 1 Answer
2D UI in 3D space 3 Answers