I'm trying to spawn a prefab at a specific Spine bone but it spawns at the wrong spawning point. It should spawn at the gun barrel. See image attachment. I have scaled up this Spine character, can that be it?

This is the code:
var delta = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;

Vector2 firePointPosition = aimPointBone.GetLocalPosition();

if (delta.x > 0)
{ // mouse is on right side of player
Transform trail = Instantiate(BulletTrailPrefab, firePointPosition, Quaternion.Euler(aimPointBone.WorldRotationX, aimPointBone.WorldRotationY, 0f + offSetZ));
LineRenderer lr = trail.GetComponent<LineRenderer>();

if (lr != null)
lr.SetPosition(0, firePointPosition);
lr.SetPosition(1, hitPos);

Destroy(trail.gameObject, 0.04f);


Vector2 firePointPosition = new Vector2(aimPointBone.WorldX * transform.localScale.x, aimPointBone.WorldY * transform.localScale.y);
made it work!
Bu mesaja eklenen dosyaları görüntülemek için gerekli yetkilere sahip değilsiniz.
  • Mesajlar: 14


Glad you've figured it out, thanks for letting us know.

Please note that there are even easier solutions available when using spine-unity, e.g. by using a BoneFollower component to let a GameObject follow a target bone.
Kullanıcı avatarı

  • Mesajlar: 4449

Dön Runtimes