Home > other >  I need a vector to be in a specific place
I need a vector to be in a specific place

Time:11-12

In this unity game, I'm writing a mod for there are humans and I'm making a human explode once it is killed but the explosion defaults to the same place on the map,

ModAPI.OnDeath  = (sender, life) => {
    ExplosionCreator.Explode(new ExplosionCreator.ExplosionParameters
        {
            Position = new Vector3(5, 5, 5),
            CreateParticlesAndSound = true,
            LargeExplosionParticles = false,
            DismemberChance = 0.1f,
            FragmentForce = 8,
            FragmentationRayCount = 32,
            Range = 10
        });   

How would I make it so that the position of the explosion is always wherever the human died?

CodePudding user response:

You have to get the human position on the map and set it in the position parameter. You cant set it to 5, 5, 5 cause it is taking positions relative to the map, not the entity.

CodePudding user response:

I have no idea how your modding framework works but to me it looks like sender is the Entity that died

ModAPI.OnDeath  = (sender, life) => {
ExplosionCreator.Explode(new ExplosionCreator.ExplosionParameters
    {
        //Assuming you can use default Unity syntax
        Position = sender.gameObject.transform.position,
        CreateParticlesAndSound = true,
        LargeExplosionParticles = false,
        DismemberChance = 0.1f,
        FragmentForce = 8,
        FragmentationRayCount = 32,
        Range = 10
    }); 

As I said I don't know what game or framework you are using but at least this concept should give you the wished result

  • Related