• Unity
  • Looking For a Full Example of Aiming and Shooting Target

  • تم التحرير
Related Discussions
...

In unity 4. example for getting started there is a spineboy who can aim and shooting where the mouse position.(and run and

jump at the same time). But when i try to do like this example i cant do it like in this tutorial. And i cant find the bone which

called shoot target for spineboy.

And when i open spineboy character in spine there is lots of constraints. But this constraints

arent locked down the target which calls crosshair.And spineboy can run jump , shoot without locking his bones to crosshair
bone. I want to know how can i do that too. And in spine i cant find the bone which calls shoot target in unity.

When i try to add the bones same as spineboy pro, In setup my bones are locking down

constraints with crosshair.Cant figure it out how to do as spineboy Pro in spine. And when i added the script spineboy

Target Controller in unity for target i add my

crosshair bone it follows the mouse but when i press "Fire"in unity my shooting animation target locks where he is looking in

spine position like in animation not mouse position where is mouse positioning in unity.

maybe someone who did aiming for his/her character can help me to understand how to do it.

We have dedicated a documentation page about this setup, you can find it here:
Spineboy example: Aiming
Does this help?

sorry but it didnt help to me . Because in Unity i cant find the bones as i said in 4.tutorial. If there is a video or someone who did it before can explain me. I will be happy. Thank you

Arda Serttunali wrote

And i cant find the bone which called shoot target for spineboy.

Now I better understand your question. The formatting of your text made it a bit hard to comprehend at first read.
It is called crosshair in the Spine example project Spineboy instead of shoot target. The Spineboy-unity example asset included in the spine-unity runtime has been especially modified by Pharan for the Unity example scenes. This is unfortunate indeed, sorry for the trouble and thanks for reporting. I will change the example scene (which remained unchanged for a very long time) to use the exact same Spineboy asset as included in the latest Spine versions. Until then you have the option of Import Data .. in the main menu in Spine to import the Spineboy-unity.json file and check out the project with the exactly same names.

Regarding your questions about "locking down": I still do not quite understand your questions in this regard. Do you mean that the constraint is always applied 100% instead of e.g. being inactive in idle and 80% active in your aim animation? This is done via the constraint's Mix parameter, which can be keyed in animations. From the example page:

The Mix values define how much effect the constraint has when moving the crosshair bone.

In case I misunderstood your questions, please explain again what you are trying to achieve in different words.


I have just uploaded a new unitypackages thyat contain an updated version of the 4 Object Oriented Sample example scene using the Spineboy-pro asset included as Spine example project.

You can download the unitypackages here as usual:
Spine Unity Download

Thanks for reporting this issue!

In spine for spineboypro , at animations segmants the aim animation of the character look to the crosshair point.

But in the rest of the animations (exp idle , jump, portal etc) it doesnt lock on the crosshair.

But when i try in my own animation and with my own model, Every single animation is locking to crosshair.(which i dont want)

I try to figure out SpineBoyPro how to do it. But there is no clue about it on the list of the animations.

Is there a guide how do it like in SpineBoyPro or any tips for lock or unlock targetting for animations.

Thank You

Arda Serttunali wrote

But when i try in my own animation and with my own model, Every single animation is locking to crosshair.(which i dont want)

Please see my posting above, your question has been answered there already:

Harald wrote

This is done via the constraint's Mix parameter, which can be keyed in animations. From the example page:

The Mix values define how much effect the constraint has when moving the crosshair bone.

In case I misunderstood your questions, please explain again what you are trying to achieve in different words.

4 أعوام لاحقا

I wanted to return to this point, since it seems to be of common interest to the community, maybe you can help me, I hope you can explain. I have created a character in Spine2D, with the crosshairs on an ik, to be able to control from Unity. Perhaps my question is more oriented to Unity, but if you can give me some information I would appreciate it. A little more detail, my character has a shotgun, which I decide from the code when to equip it, to do this, I created animations in spine, to equip, store the shotgun. The complexity I am having is the following, when I import from Unity, I am importing my character as SkeletonMecanim. When I import, I generate the bone hierarchy for everyone to follow the animation. What is complicating me is the mixture of animations, since my character can walk, run, equip a shotgun and I must mix animations for the lower part of the body and the upper part. After so many attempts, I managed to understand it this way. In the animator, I have created another layer, to equip the weapon, if I equip the weapon and walk, I do the arm movement from the aiming layer, since when equipping the weapon, it remains in that animation, and I must mix between the layer animator base, and pointing base. What is being complex for me is that in order to move the aimtarget's IK, I must change the bone at runtime so that it appears as an override, and thus be able to control it, the issue is that if I want to roll with the character, for example, or running or walking with the weapon, I must instantly return this aiming bone to Follow, otherwise the animations do not behave correctly. Do you understand what I'm trying to do? I would like and appreciate any help you can give me, since I couldn't solve it from code, or if there is another way to go. But the idea is that the character, by pressing a button, equips the weapon, can roll with it to evade enemies, and this bone is only enabled when he remains in the weapon equipped animation, where the shotgun and the aimtarget remain at one point. so you can override and control the scope. On the other hand, the character can also store his weapon on his back. I have not found anything similar, if when the weapon is fixed in one hand, that seems simpler. I appreciate your time reading it, I am self-taught, I have not studied spine or unity, I simply learned by trial and error. I am from Argentina, I bought the pro license, and I am very happy with the product, but my game is now stagnant because of this. I don't know how to solve it in a simpler way, I hope it is understood, otherwise I can add images of both spine and unity to make it clearer. thank you.

    sjpalacio

    The issue is that if I want to roll with the character, for example, or running or walking with the weapon, I must instantly return this aiming bone to Follow, otherwise the animations do not behave correctly.

    hmm, I would think that if you simply stop the override, but the animation continues to be applied, the aiming bone should return to follow, but you have tried that on your end and it didn't work? (You may need to add keys to set the IK mix value at the first frame of the running and walking animation.)
    Since you said you "couldn't solve it from code," please show us the code you tried.

    By the way, we would appreciate it if you would create a new post instead of continuing this old thread. This is a case of using the SkeletonMecanim component, and since the conditions will be different in many ways from doing the same thing with SkeletonAnimation, it is better to discuss this in a separate thread.

    I appreciate your response and suggestion, apologies, I tried to get the bone to follow between animations again, but I can't find an optimal way to do it at runtime. Once the weapon is equipped and putting the IK to override to be able to control it, it works correctly, but then when going to another animation, when following it again in the sight bone configuration, for example if I put the shotgun away, the animation no longer plays correctly . But then I raise the doubt in another thread. Thank you again and a thousand apologies.

    12 أيام لاحقا

    sjpalacio I must change the bone at runtime so that it appears as an override, and thus be able to control it, the issue is that if I want to roll with the character, for example, or running or walking with the weapon, I must instantly return this aiming bone to Follow, otherwise the animations do not behave correctly.

    Your setup is incorrect (not following typical conventions). You need to set up your IK and bone hierarchy so that the IK-target bone can always be positioned and left at any target during all animations, and the IK constraint's mix value (0.0=off, 1.0=active) shall be used to smoothly switch the hand from e.g. your "normal" walking animation to a targeted one (e.g. when grabbing a door handle). The SkeletonUtilityBone component is not intended to switch between modes Follow and Override at runtime.