- Home /
Trying to rotate my character to the position of my touch on mobile
I want my character to rotate to the position I touch on my screen. I want to be able to drag 360 degreees around it so it rotates in all direction. I also want to make sure when I move my joystick it does not change the direction the character is looking in. this is what I have for joystick movement: public Rigidbody2D rb; public float moveSpeed = 5f;
public Joystick joystick;
Vector2 movement;
Vector2 mousePos;
public float rotSpeed = 20f;
private void Start()
{
mousePos = transform.position;
}
// Update is called once per frame
void Update()
{
movement.x = joystick.Horizontal ;
movement.y = joystick.Vertical;
}
void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
Answer by Charlie010903 · Jan 29, 2020 at 07:50 PM
Also when i am rotating it could someone try to make sure it doesnt lock back to its original postion I have had lots of problems with this
Your answer
Follow this Question
Related Questions
How to rotate an object using touch controls 3 Answers
How do I move an object with my finger?[C#] 1 Answer
Possible to get touch area data? 1 Answer
Can't solve hitbox issues in mobile game 1 Answer
Update rotation from touch and drag 1 Answer