Untitled
Never
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMouvement : MonoBehaviour { private float rad; private float deg; private Rigidbody2D body; public float Speed; void Start() { body = GetComponent<Rigidbody2D>(); } void FixedUpdate() { Vector2 Target = Camera.main.ScreenToWorldPoint(Input.mousePosition); //Target.z = transform.position.z; float deltaX = Target.x - transform.position.x; float deltaY = Target.y - transform.position.y; //transform.position = Vector3.MoveTowards(transform.position, Target, Speed * Time.deltaTime / transform.localScale.x); float rad = Mathf.Atan(deltaY / deltaX); Debug.Log(rad); if (rad > 0) { Debug.Log("Angle is greater than 0, so should be between 0 and 90."); // Going down and to the left, so convert to Quadrant III if (deltaX < 0) { Debug.Log("Moving to the left with deltaX = " + deltaX + ", so convert to Quadrant III"); rad = Mathf.PI + rad; } else { Debug.Log("In Quadrant I, so keeping angle of " + rad); } } // Initial angle is -90-0, so either in Quadrant II or Quadrant IV else if (rad < 0) { Debug.Log("Angle is less than 0, so should be between -90 and 0."); // Going to the left, so convert to Quadrant II if (deltaX < 0) { Debug.Log("Moving to the left with deltaX = " + deltaX + ", so convert to Quadrant II"); rad = Mathf.PI - rad; } // Going to the right, so convert to Quadrant IV with a positive angle value else if (deltaX > 0) { Debug.Log("Going to the right, so in Quadrant IV. Converting from " + rad + " to " + ((Mathf.PI * 2) - rad)); rad = (Mathf.PI * 2) - rad; } } // Angle is 0, so need to check if actually 0 or 180 deg else { if (deltaX < 0) { rad = Mathf.PI * 2; } } deg = rad * Mathf.Rad2Deg; body.MovePosition(new Vector2((transform.position.x + Target.x * ((Speed * Mathf.Sin(rad)) * Time.fixedDeltaTime / transform.localScale.x)), transform.position.y + Target.y * ((Speed * Mathf.Cos(rad)) * Time.fixedDeltaTime / transform.localScale.y))); } }
Raw Text
-
FAMILY SINNERS - Naughty Babe Demi Hawks Finally Gets In Her Hot Step Uncle Derrick Pierce's Pa
2 min ago
-
Untitled
28 min ago
-
A redhead schoolgirl came to the guy's house
33 min ago
-
Untitled
54 min ago
-
SG Mechanical Emergency AC Repair
58 min ago
-
Big Butt Maya Farrell Swaps Oral Skills And Takes A Pussy Creampie
1 hour ago
-
zauran
1 hour ago
-
Untitled
1 hour ago
-
https://www.macombdaily.com/2024/03/27/the-growth-matrix-reviews-2024-legit-growth-matrix-or-hidden-
1 hour ago
-
hungry student masturbates, I saw and fucked her. cum in mouth
1 hour ago