- Home /
Animation not at correct position W/Video
Hey guys! Hope you can help me fix my problem with the animation! Here is the video: https://www.youtube.com/watch?v=6Zs2nlGTKAo
Here are the scripts:
WeaponsStats Script:
using UnityEngine;
using System.Collections;
public class WeaponStats : MonoBehaviour {
public bool damaging;
public bool attacking;
public int weaponShortSwordMinDamage;
public int weaponShortSwordMaxDamage;
Animator anim;
public int attachedToWhat;
int addTorque;
public bool dropped;
public bool pickingUp;
void Start () {
anim = GetComponent<Animator>();
}
void Update () {
if (Input.GetMouseButtonDown(0) && attachedToWhat == 0)
{
anim.SetTrigger("Attack");
}
if (attachedToWhat == 2)
{
if(transform.parent.GetComponent<BasicAI_1>().attackObject == true)
anim.SetTrigger("Attack");
}
if (transform.root.tag == "Player" && transform.root.tag != "Enemy"){
attachedToWhat = 0;
collider2D.isTrigger = true;
anim.enabled = true;
rigidbody2D.isKinematic = true;
rigidbody2D.interpolation = RigidbodyInterpolation2D.None;
dropped = false;
transform.localScale = Vector3.one;
//transform.localPosition = new Vector3(0.3125f, 0.25f, 0f);
}
if (transform.root.tag == "Enemy" && transform.root.tag != "Player"){
attachedToWhat = 2;
collider2D.isTrigger = true;
anim.enabled = true;
rigidbody2D.isKinematic = true;
rigidbody2D.interpolation = RigidbodyInterpolation2D.None;
dropped = false;
}
if (transform.root.tag != "Player" && transform.root.tag != "Enemy"){
attachedToWhat = 1;
collider2D.isTrigger = false;
anim.enabled = false;
rigidbody2D.isKinematic = false;
rigidbody2D.interpolation = RigidbodyInterpolation2D.Interpolate;
Physics2D.IgnoreLayerCollision(14, 16);
if(rigidbody2D.rotation == 0)
rigidbody2D.AddTorque(1000);
dropped = true;
}
if(pickingUp == true){
Debug.Log("Got Picked Up");
transform.localPosition = new Vector3(0.3125f, 0.25f, 0f);
}
}
void attackingFalse(){
damaging = false;
attacking = false;
}
void attackingTrue(){
attacking = true;
}
}
PickUp Script:
using UnityEngine;
using System.Collections;
public class PickUpSensorScript : MonoBehaviour {
public LayerMask objectUsers;
public Transform weapon;
//public float positionToUserX 0.3125;
// public float positionToUserY ;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerStay2D(Collider2D other) {
if(transform.parent.GetComponent<WeaponStats>().dropped == true && other.tag == "Player")
if(other.GetComponent<PlayerController>().pickUp == true){
Debug.Log("Picked Up");
other.GetComponent<PlayerController>().pickUp = false;
weapon.transform.parent = other.transform;
}
}
}
Hope you can help!
Comment