AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Create an entity and make it spin (https://forums.alliedmods.net/showthread.php?t=309125)

scorpius2k1 07-14-2018 11:22

Create an entity and make it spin
 
How would I go about making an entity spin in a randomized direction after I spawn it? I understand the direction and velocity parts, etc, I just need to know how to do the spin part. I have played around with the "angles" with TeleportEntity, but it doesn't seem to do what I am needing.

Just think if something exploded how the pieces go it random directions and spin - that's what I am after.

PHP Code:

stock CreateEntityAndSpin()
{
    
decl iEntity;
    
iEntity CreateEntityByName("prop_physics");

    if(
IsValidEntity(iEntity))
    {
        
// Spawn entity and make it spin...
    
}


Thanks in advance! :bacon!:

mug1wara 07-14-2018 12:02

Re: Create an entity and make it spin
 
PHP Code:

float fVector[3];

fVector[1] = 360.0/* If not obvious, one rotation... ^^ */

SetEntPropVector(iEntityProp_Send"m_angRotation"fVector); 


Totenfluch 07-14-2018 13:56

Re: Create an entity and make it spin
 
Source Hacks incoming!

PHP Code:

stock CreateEntityAndSpin() { 
    
int iEntity
    
iEntity CreateEntityByName("prop_physics"); 

    if(
IsValidEntity(iEntity)) 
    { 

      
int m_iRotator CreateEntityByName("func_rotating");
      
DispatchKeyValueVector(m_iRotator"origin"pos);
      
DispatchKeyValue(m_iRotator"targetname""Item");
      
DispatchKeyValue(m_iRotator"maxspeed""200");
      
DispatchKeyValue(m_iRotator"friction""0");
      
DispatchKeyValue(m_iRotator"dmg""0");
      
DispatchKeyValue(m_iRotator"solid""0");
      
DispatchKeyValue(m_iRotator"spawnflags""64");
      
DispatchSpawn(m_iRotator);
    
      
SetVariantString("!activator");
      
AcceptEntityInput(iEntity"SetParent"m_iRotatorm_iRotator);
      
AcceptEntityInput(m_iRotator"Start");
    
      
SetEntPropEnt(iEntityProp_Send"m_hEffectEntity"m_iRotator);
    }


Proably useful for you: https://github.com/Totenfluch/EventI...pawner.sp#L363

scorpius2k1 07-20-2018 13:19

Re: Create an entity and make it spin
 
Thanks for the replies. Unfortunately, this isn't not exactly what I was after...I am not looking to simply rotate a prop, but actually cause it to spin through the air. Using a func_rotating is just not feasible and I want to do this without any hacky calls.

A good example of what I am experiencing:
- Create a prop
- Spawn it in the air
- It stays in the same position *until* it hits the ground
- Once it hits the ground, the game physics engine itself causes the spin
- I need to make that spin happen right after spawning (in the air)

I am able to get it to spin in the air if the prop is damaged (using a point_hurt to damage it after spawning)...however this is creating other problems and is quite hacky as well and probably not necessary.

All I am after is to get that prop_physics spinning before it hits the ground. This thread seems to depict precisely what I am after, but I cannot get it to work with TF2/HL2DM since 'm_vecAngVelocity' is not found in 'prop_physics'

https://forums.alliedmods.net/showthread.php?t=233554

Thanks again all


All times are GMT -4. The time now is 04:34.

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