Jump to content

Collision Detection

Closed 1.0.2

fiftysnens
fiftysnens

Posted

Hi, iam currently editing the Biplane plugin to my needs and i encountered a point where i dont know how to proceed.

I tryed to add damage detection for when the plane collides with terrain by using Hitinfo but iam not mistaken by my privous attempts, damage dealt by anything that is not a player / projectile is not handled via Hitinfo ? If thats the case is theer any other way of detecting the collision ? 

I thought about checking the prefabs velocity for a sudden drop of more then ~15, but can not figure out a way to compare it to 1 or 2 frames before as the only thing i know that comes close to this would be NextTick but i doubt it can be used here.

Thanks for any advise or Ideas you might have !  

If you would like to see what i did so far, i have asked the same question on umod with a code example (dont worry i did not publish your work)

https://umod.org/community/rust/41441-detect-plane-collison?page=1#post-2

 

 

Adem

Posted

3 hours ago, fiftysnens said:

Hi, iam currently editing the Biplane plugin to my needs and i encountered a point where i dont know how to proceed.

I tryed to add damage detection for when the plane collides with terrain by using Hitinfo but iam not mistaken by my privous attempts, damage dealt by anything that is not a player / projectile is not handled via Hitinfo ? If thats the case is theer any other way of detecting the collision ? 

I thought about checking the prefabs velocity for a sudden drop of more then ~15, but can not figure out a way to compare it to 1 or 2 frames before as the only thing i know that comes close to this would be NextTick but i doubt it can be used here.

Thanks for any advise or Ideas you might have !  

If you would like to see what i did so far, i have asked the same question on umod with a code example (dont worry i did not publish your work)

https://umod.org/community/rust/41441-detect-plane-collison?page=1#post-2

 

 

If you have my jetpack plugin, then you can find a solution there

Adem

Posted

If not, then write to me in the discord Adem#9554

fiftysnens

Posted (edited)

I do not own the usage right, but i will message you in discord. thanks up front

Edited by fiftysnens
fiftysnens

Posted

Hi, iam still not getting the hang of it. I understand if you dont have the time, but i assume u are the best person to ask.

Iam getting this error message:

Failed to call hook 'OnEntityTakeDamage' on plugin 'Biplane v1.0.2' (NullReferenceException: Object reference not set to an instance of an object)
  at Oxide.Plugins.Biplane.OnEntityTakeDamage (BaseEntity entity, HitInfo info, UnityEngine.Rigidbody rigidbody, ModularCar modularCar) [0x00014] in <4c56633b7e3a49d69e6a187890c517f7>:0 
  at Oxide.Plugins.Biplane.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00192] in <4c56633b7e3a49d69e6a187890c517f7>:0 
  at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <60c318df79ed41688ea59335e48d61ad>:0 
  at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <50629aa0e75d4126b345d8d9d64da28d>:0 
  at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <50629aa0e75d4126b345d8d9d64da28d>:0

the code refferanced would be:

object OnEntityTakeDamage(BaseEntity entity, HitInfo info, Rigidbody rigidbody, ModularCar modularCar)
        {
                                        rigidbody = modularCar.rigidBody;
                                        float speed = rigidbody.velocity.magnitude;

                                                if (entity == null || info == null) return null;
                                                if ((entity.ShortPrefabName.Contains("kayak")&&(speed <=14)) || (entity.ShortPrefabName.Contains("boogieboard")&&(speed <=14)) || (entity.ShortPrefabName.Contains("engine")&&(speed <=14)))
                                                {
                                                        BiplaneComponent biplaneComponent = biplanes.FirstOrDefault(x => x.subEntities.Contains(entity));
                                                        if (biplaneComponent == null) return null;
                                                        biplaneComponent.modularCar.Hurt(info);
                                                NextTick(() =>
                                                {
                                                var damagetaken = info.damageTypes.Total();
                                                        if (damagetaken >= 15)
                                                        {
                                                                Effect.server.Run("assets/content/vehicles/minicopter/debris_effect.prefab", entity.transform.position);
                                                                var fireball = GameManager.server.CreateEntity("assets/bundled/prefabs/fireball.prefab", entity.transform.position);
                                                                if (fireball == null) return;
                                                                fireball.Spawn();
                                                                biplaneComponent.modularCar.Kill();
                                                        }
                                                });
                                                        return true;
                                                }
                                                        else if ((entity.ShortPrefabName.Contains("kayak")&&(speed >=15)) || (entity.ShortPrefabName.Contains("boogieboard")&&(speed >=15)) || (entity.ShortPrefabName.Contains("engine")&&(>
                                                {
                                                        return null;
                                                }
                return null;
        }

 

Adem

Posted

Changed Status from Pending to Closed

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.1k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.