[0.11.4] Projectiles Spells/Arrows Have Collision

Post here if you need help getting started with Daggerfall Unity or just want to clarify a potential bug. Questions about playing or modding classic Daggerfall should be posted to Community.
Post Reply
User avatar
Magicono43
Posts: 1137
Joined: Tue Nov 06, 2018 7:06 am

[0.11.4] Projectiles Spells/Arrows Have Collision

Post by Magicono43 »

So I finally decided to stop being lazy and just make a quick bug report on this. So this issue has been happening for many more versions than the above listed most recent build, and the title may not be the proper way to word the problem.

Anyway, when arrows or spell projectiles are flying through the air, instead of having collision that would allow for them to detect when they actually touch something solid like the player, an enemy entity, or a wall, etc, BUT not having that projectile actually cause a physical obstruction itself while flying. I'm probably wording this poorly, but basically when an arrow or spell is flying through the air, it seems to make a sort of physical sphere object around it, that does not just detect when it hits something, but also is a physical obstruction for things such as AI path-finding and often when colliding with the player it will jerk then around in weird ways, or even get the player stuck in place for a moment.

Now I don't know if there is a way to deal with this in Unity, such as making the object have collision logic, but basically making the thing itself incorporeal to other objects so they don't get physically obstructed by it. This "bug" is very noticeable when playing with a bow, since you will see your target shuffle around in weird ways when the arrow gets near them as if their pathing AI is trying to figure out a way around the projectile being thrown.

Hopefully you get the idea, no idea how it worked in DOS Daggerfall, as arrows were simply a hit-scan ray that completely ignored all obstructions, and spell projectiles I have no idea how those worked honestly, but I don't recall DOS AI every shuffling around to path around a flying spell, nor the player getting physical shuffled around when getting hit by flying spells.

Maybe the solution is as simple as a setting on whatever pre-fab object is created whenever a projectile is created, no idea on that one, thanks for reading.

User avatar
Kab the Bird Ranger
Posts: 123
Joined: Tue Feb 23, 2021 12:30 am

Re: [0.11.4] Projectiles Spells/Arrows Have Collision

Post by Kab the Bird Ranger »

Arrows and spell projectiles are almost entirely different when it comes to collisions, so let's treat them separately. Also, the potential issues with collisions are different for players and for AI. For players, we don't want the projectile hits to obstruct with movement in ways that differ from DOS. For AIs, we don't want projectiles to be considered as an "obstacle" when it comes to finding a path for their objective.

For reference, arrows aren't solid (ie: their collision is a Trigger), but spells are, at least until they hit something.

So, we have 4 scenarios we need to consider:

1. when an arrow hits the player
2. when a spell hits the player
3. when an arrow is shot towards an AI
4. when a spell is fired towards an AI

From chat discussions outside this thread, we're not sure #1 actually has any issues. More testing needed.

Personally, I was looking into #3. I think most people's experience is that shooting arrows at AIs makes them behave strange, as if each arrow suddenly gave them hesitation to reach towards you for a short time.

My preliminary investigation points me toward this section of the EnemyMotor, the "ObstacleCheck".
https://github.com/Interkarma/daggerfal ... r.cs#L1107

I know from tests that the CapsuleCast will detect Triggers, that's how it detects doors. As I've pointed out above, arrows are triggers, and therefore will be detected before the player, and therefore "obstacleDetected" will be left as "true", and the NPC will start doing a detour until the arrow disappears (or gets out of the way otherwise).

If we wanted to fix this, we could start by removing triggers from this cast, but then doors would have to be detected another way.

If anyone knows more about this particular scenario, please share your experience.

User avatar
DunnyOfPenwick
Posts: 275
Joined: Wed Apr 14, 2021 1:58 am
Location: Southeast US

Re: [0.11.4] Projectiles Spells/Arrows Have Collision

Post by DunnyOfPenwick »

It's possible projectiles are interfering with EnemySenses.CanSeeTarget(), as the projectiles are typically flying close to eye level.

The use of layers when raycasting might help with this problem. Maybe we should replace the standard Unity raycast with some daggerfall-specific utility functions that make it easy for developers and modders to perform better racycasts.

e.g.
Daggerfall.RayCast(src, direction, out hit, DaggerfallLayers.Terrain)

Post Reply