- Змінено
Bullet - Clone
Hallo,
mein Problem mit der Shootind-direction ist zwar noch nicht gelöst, aber geradeaus kann der Player schießen.
Also habe ich schon mal ein spawn eingerichtet und einen bullet Prefab definiert.
clone = Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
clone.AddForce(bulletSpawn.transform.right * bulletSpeed);
Beim Ausführen wird auch ein Clone erstellt, aber der Player (Spineboy) selber, nicht der BulletPrefab. Die Clone werden bei jedem Click verdoppelt. Bei anderen Pbjekten außer Spines funktioniert das Schießen mit Bullets ?
Wo könnte der Fehler liegen ?
If that code is causing a copy of the Player to be instantiated, then your "bulletPrefab" is probably not set to your actual bullet prefab (either that, or for some reason your bullet prefab has a copy of the Player in it).
Spine gameobjects are just one way of displaying a graphic on the screen - it has nothing specifically to do with bullets or prefabs. You can put whatever you want in a prefab - for instance, if you create a bullet prefab, you could use a Sprite as the graphic (instead of a SkeletonAnimation).
Google translate:
Wenn dieser Code dazu führt, dass eine Kopie des Players instanziiert wird, ist Ihr "bulletPrefab" wahrscheinlich nicht auf Ihr tatsächliches Bullet-Prefab eingestellt (entweder das oder aus irgendeinem Grund enthält Ihr Bullet-Prefab eine Kopie des Players).
Spine-Spielobjekte sind nur eine Möglichkeit, eine Grafik auf dem Bildschirm anzuzeigen – sie haben nichts speziell mit Kugeln oder Fertigteilen zu tun. Sie können in ein Prefab einfügen, was Sie wollen. Wenn Sie beispielsweise ein Bullet Prefab erstellen, können Sie ein Sprite als Grafik verwenden (anstelle einer SkeletonAnimation).
Thank you for your prompt reply .
It's clear now. The shoot was in the PlayerAction script. I assigned a bullet script with the cloning to the spawn point.
Spineboy now shoots bullets too.