- Home /
Question by
Pendragon420 · Oct 04, 2014 at 08:55 AM ·
2dinstantiateparentchild
Instantiate as child Issue regarding 2D platformer melee system
basically i wanted to put melee in my 2D game, the way i'm going about it is by instantiating a box collider prefab (with animations) at a set point called AttackSpawn (a child of my player). i managed to instantiate the attack box but i want it to follow my player (currently it spawns a static box). i was thinking if i made the attack a child of the player it would follow but i dont know how to do this. my code currently is this
using UnityEngine;
using System.Collections;
public class ActionManager : MonoBehaviour {
public Transform Attack;
public Transform AttackSpawn;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1"))
{
Instantiate(Attack, AttackSpawn.position, AttackSpawn.rotation);
}
}
}
thanks for your help guys hopefully i can work this out :)
Comment
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Prefab clones behaviour 0 Answers
How to find and remove the last child of parent? 1 Answer
Create Clones as children in loops? 1 Answer
Prefab, procedural attachment of child, childCount return 0 1 Answer