AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved prop_dynamic collison not rotating? (https://forums.alliedmods.net/showthread.php?t=332691)

Johnny2525 05-27-2021 14:26

prop_dynamic collison not rotating?
 
Hi

So basically when I am teleporting newly created prop_dynamic object I am also rotating it, the model seems to be rotated but the model collision stays at angle 0 so it creates that "invisible wall" effect while the model is actually rotated.

Code:

wallModel = "models/props/hr_massive/wood_fence/wood_fence_128.mdl"

Ent = CreateEntityByName("prop_dynamic_override");
if(Ent != -1) {
        pos[0] = pos[0] + (fForward[0] * 107.0);
        pos[1] = pos[1] + (fForward[1] * 107.0);
        pos[2] = pos[2] + (fForward[2] * 107.0);

        DispatchKeyValue(Ent, "model", wallModel);
        DispatchKeyValue(Ent, "solid", "2");
        DispatchSpawn(Ent);

        float objAngles[3];
        objAngles[0] = 0.0;
        objAngles[1] = 0.0;
        objAngles[2] = 0.0;

        objAngles[1] = 90.0;
               
       
        //SetEntPropVector(Ent, Prop_Send, "m_angRotation", objAngles);
        TeleportEntity(Ent, pos, objAngles, NULL_VECTOR);
       
        SetEntityRenderMode(Ent, RENDER_TRANSCOLOR);
        SetEntityRenderColor(Ent, 255, 255, 255, 255);
       
        SetEntProp(Ent, Prop_Data, "m_takedamage", DAMAGE_YES, 1);
        SetEntProp(Ent, Prop_Data, "m_iHealth", 65);
}

https://i.imgur.com/uP4iVni.jpg

Does it have something to do with the model by itself?
If somebody could help me with this case :)

andi67 05-28-2021 06:46

Re: prop_dynamic collison not rotating?
 
Code:

        float objAngles[3];
        objAngles[0] = 0.0;
        objAngles[1] = 0.0;
        objAngles[2] = 0.0;

        objAngles[1] = 90.0;

maybe you should simply try:

Code:

        float objAngles[3];
        objAngles[0] = 0.0;
        objAngles[1] = 90.0;
        objAngles[2] = 0.0;


Johnny2525 05-28-2021 07:01

Re: prop_dynamic collison not rotating?
 
I've searched a little more and found couple of lines which I added to my code, and it works.

Code:

DispatchKeyValue(Ent, "Solid", "6");
SetEntProp(Ent, Prop_Data, "m_nSolidType", 6);
DispatchKeyValue(Ent, "spawnflags", "8");
SetEntProp(Ent, Prop_Data, "m_CollisionGroup", 5);
DispatchSpawn(Ent);
AcceptEntityInput(Ent, "EnableCollision");

I didn't really have time to understand why it works now but I hope its gonna help somebody


Code:

wallModel = "models/props/hr_massive/wood_fence/wood_fence_128.mdl"

Ent = CreateEntityByName("prop_dynamic_override");
if(Ent != -1) {
        pos[0] = pos[0] + (fForward[0] * 107.0);
        pos[1] = pos[1] + (fForward[1] * 107.0);
        pos[2] = pos[2] + (fForward[2] * 107.0);

        DispatchKeyValue(Ent, "model", wallModel);
        DispatchKeyValue(Ent, "Solid", "6");
        SetEntProp(Ent, Prop_Data, "m_nSolidType", 6);
        DispatchKeyValue(Ent, "spawnflags", "8");
        SetEntProp(Ent, Prop_Data, "m_CollisionGroup", 5);
        DispatchSpawn(Ent);
        AcceptEntityInput(Ent, "EnableCollision");

        float objAngles[3];
        objAngles[0] = 0.0;
        objAngles[1] = 0.0;
        objAngles[2] = 0.0;

        objAngles[1] = 90.0;
               
       
        //SetEntPropVector(Ent, Prop_Send, "m_angRotation", objAngles);
        TeleportEntity(Ent, pos, objAngles, NULL_VECTOR);
       
        SetEntityRenderMode(Ent, RENDER_TRANSCOLOR);
        SetEntityRenderColor(Ent, 255, 255, 255, 255);
       
        SetEntProp(Ent, Prop_Data, "m_takedamage", DAMAGE_YES, 1);
        SetEntProp(Ent, Prop_Data, "m_iHealth", 65);
}



All times are GMT -4. The time now is 13:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.