Add 3d arrow projectiles#980
Conversation
|
Is this an update over classic? Or are arrows actual projectiles in classic then? I assumed not because arrows that don't hit a target are lost. |
|
They are in classic, it's just hard to see them because of the low screen resolution. Do a frame-by-frame in a well-lit area like a castle throne room and you'll see them. |
|
Tweaked the position of the arrow a bit (it closely matches the sprite when shooting with a level view now) and slightly slowed the arrows as they were a little too hard to see. |
912249f to
e47389c
Compare
|
Made arrow impact use doppler. |
I started with doppler for spell missiles and removed it because it just made spells sound weak and ineffective at range. It may not be "realistic", but removing doppler makes them feel punchier and more energetic on impact. They're much more satisfying without.
If you use a BoxCollider, Unity should create a minimum fitting box around the projectile. If you want to make collisions a bit more generous, you could manually add a box collider and tweak dimensions to where happy. It should be fine as kinematic, provided it's not marked as a trigger. I had to change this earlier when I learned the hard way that triggers use their own different physic implementation and may not be reliable in complex trigger-to-mesh environments. |
|
Good job on this, it looks fine on a read. I'll play with it when I can and offer any feedback. Thanks for putting all this together! 👍 |
I tried using a BoxCollider instead of a SphereCollider, assuming that's what you mean, but the error still happens. Seems like the problem is with the Rigidbody component, not the collider type. This isn't a blocker for me. Hopefully using a better physics solution would solve the problem with the arrows sometimes pushing the entity (player or enemy) when they collide, but I don't know that it would. |
Can you explain what the error you're encountering is exactly? I'm not really clear on the problem you encountered. I'll try to help if I can. :) |
|
I quoted it, the message starting with "Non-convex MeshCollider" Same as with the SphereCollider, if I make the Rigidbody have "Is Kinematic" checked, the error won't appear, but |
|
Apart from easy 3D model helpers, the missile class was written from the start to support arrows - any kind of missile in fact. Its missile agnostic. All the collision handling you need is already in there for you. Either a SphereCollider or BoxCollider will be fine. I'll add an example for you when I can over weekend and we can rework PR from there. :) |
| // Offset up so it comes from where it looks like it should from on the enemy sprites | ||
| if (caster != GameManager.Instance.PlayerEntityBehaviour) | ||
| adjust = new Vector3(0, 0.6f, 0); | ||
| else // Offset forward to avoid collision with player and to the right to match bow animation |
There was a problem hiding this comment.
Remember there's an option to switch weapons to left hand.. looks wierd with a bow but is possible.
There was a problem hiding this comment.
Thanks, fixing it now.
There was a problem hiding this comment.
This part is fine, as that option just draws the weapon to the left, but bows are still equipped in the right hand. But the arrow won't spawn in the right place, so I have to fix that.
There was a problem hiding this comment.
Fixed the arrows to appear correctly when this option is on.
|
I'll send this to an "arrows" branch on my side and we can collab on it. Let me know when you're clear and tag me in. I'm going to revert some of the changes to the missile class if that's OK. It shouldn't need many changes at all to support arrows as the missile class doesn't care what kind of missile it is. Even the 3D arrow can be done through composition (i.e. add another component to missile prefab for arrow itself) rather than modify the missile class directly. Anyway, I've got to get some sleep. Will help out more over weekend as I can. This is the first weekend in a while I haven't been working and my other half has organised some social events for us I've promised to be available for. :) |
|
I'm done with it for now.
Go ahead! |
I see that branch already exists, so I'll re-target it to that. |
Enjoy and relax mate - DFU stuff can wait. |
I did, sorry I forgot to mention. I just wanted to make sure you were clear before merging.
I ended up having a great weekend. Good to feel less under pressure again for once. :) Didn't quite get those builds out, but taking care of that this morning. |
Very glad to hear it. You have to pace yourself man, this is a marathon not a sprint... and we would all be screwed if you burn yaself out! |
This replaces the temporary instant arrow hits with actual 3d projectiles.
This is probably messier than it should be, as I put it together with trial and error. For example, I couldn't use the existing collider used by
DaggerfallMissile, because it won't work with the concave shape and I had to make the rigidBody kinematic. Instead I use a sphere ray cast for the arrows. Interkarma, please feel free to gut this implementation if you don't like it. Functionally, it works, though.All existing arrow code was adapted to work with it. I had to account for various things, like getting the player weapon at the time of shooting, not the time of damage calculation, since they might unequip their bow before an arrow hits the target.
Known issues:
The arrow hit sound plays without any doppler because the same code as it used for spell projectiles is used, and they aren't using doppler. (Seems to me like they should, even if classic doesn't)
When looking up or down while shooting an arrow, the arrow spawns offset from the center of the screen where it should spawn from.
There is a merge conflict with the Serializable enemy prefab in the AI combat PR, which will need to be fixed. I can update the PR as needed or you could do it yourself if you want to.
The arrows can sometimes displace enemies or the player a little bit, I think because of collision with the 3d.