I have a prefab named Spear.
It contains a script like this:
using System.Collections.Generic;
using UnityEngine;
public class PickUp : MonoBehaviour
{
public GameObject Hand;
public float WeaponDamage;
public Enemy enemyScr;
public bool IsInHand;
public void Start()
{
enemyScr = GameObject.Find("EvilTriangle").GetComponent<Enemy>();
Hand = GameObject.Find("Hand");
}
public void OnMouseDown()
{
this.transform.position = Hand.transform.position;
this.transform.parent = GameObject.Find("Hand").transform;
transform.eulerAngles = new Vector3(0, 0, 0);
GetComponent<Rigidbody2D>().isKinematic = true;
IsInHand = true;
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.Q) && IsInHand == true)
{
this.transform.parent = null;
GetComponent<Rigidbody2D>().isKinematic = false;
IsInHand = false;
}
}
}
In play mode, when I click on the spear (and it is vertical in the scene), everything is looking fine.
But when I click on the spear when it is horizontal, (and as you can see in the script, I'm trying to rotate it to 0), its scale is getting weird.
This happens every time I drop the spear vertical (while playing), it gets thinner and thinner.
I have no idea what is causing this problem.
Any help will be appreciated!