[SOLVED] Trying to create a "blast" (like Kamehameha)

The problem is that the object extends behind the player as well as in front of the player when it should only extends in front.
(Note that in the code I used a coroutine but that will change.)

using UnityEngine;
using System.Collections;

namespace Projectiles
{
        public class ElementBlast : Projectile
        {
                public float rotationSpeed;  

                protected override void Start ()
                {
                        StartCoroutine ("InGrowth");
                }


                IEnumerator InGrowth ()
                {
                        while (transform.localScale.x < 7) {
                                var g = GetComponent<CapsuleCollider> ().bounds.extents.x;
                                Debug.Log (g);
                                Debug.Log (transform.position);
                                transform.localScale += new Vector3 (.25f, 0, 0);
                                transform.position += new Vector3 (.25f * transform.parent.transform.parent.forward.x, 0, 0);
                                yield return new WaitForSeconds (.05f);
                        }
                }
        }

What are you using for the “kamehame”? Is it a sprite or is it something else?

I’m just using a Unity Cylinder for testing.

Well what you have to remember is that when you scale something, it scales from the origin point. In the case of a Unity capsule, the origin is the center. So it’s going to scale both ways.

Yea I know. I managed to fix it. It was a combination of badly set up Game Objects (strange rotations, etc.) and bad code.

I fixed it by replacing to those lines in the while loop:

                                        float step = growthSpeed * Time.deltaTime;
                                        transform.localScale += new Vector3 (step, 0, 0);
                                        transform.localPosition += new Vector3 (step / 2, 0, 0);

Better to not have a collider on it… recalculating the collider bounds every time it updates is expensive