- Home /
Update anim references in script
Hello there,
For a 2D sidescrolling platformer, i've made a little gear system here is the description :
- Player (My main player gameObject with Gear script attached)
- Gear (This gameObject is just for organization, it's named "root" in the script, and has no script attached)
Armor (the armor with sprite and Armor script)
Weapon (the weapon with sprite and Weapon script)
- Gear (This gameObject is just for organization, it's named "root" in the script, and has no script attached)
I have a script attached to Player which is Gear, with a reference to "Gear" GameObject to use it as parent transform for my future items.
In gear, I equip a weapon this way :
public void Equip(Wearable w){
switch (w.type) {
case Wearable.Type.WEAPON:
GameObject weaponGO = Instantiate(w.gameObject);
weaponGO.transform.SetParent(root.transform);
Destroy (this.weapon.gameObject);
this.weapon = w.GetComponent<Weapon>();
break;
//I did a swicth because i'll do it for armor, pets etc afterwards
}
}
The problem is that I also have an animator on the payer, to attack, move, etc...
SO when i change my weapon, it spawns at 0,0,0 and it's not following animations at all, and in my player's animations, I see"Weapon : Position (Missing !)", so i think this comes from animation references... But how to change this in my script?
Your answer
Follow this Question
Related Questions
Vehicle animation on a 2d map 0 Answers
Animating a weapon into/out of player view 1 Answer
Sprite-based animation not loading with Animation component 0 Answers
Need help on skeletal Animation 0 Answers
Switching between animations / synch 1 Answer