Raised This Month: $12 Target: $400
 3% 

Create an entity and make it spin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-14-2018 , 11:22   Create an entity and make it spin
Reply With Quote #1

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!
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-14-2018 , 12:02   Re: Create an entity and make it spin
Reply With Quote #2

PHP Code:
float fVector[3];

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

SetEntPropVector(iEntityProp_Send"m_angRotation"fVector); 
mug1wara is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 07-14-2018 , 13:56   Re: Create an entity and make it spin
Reply With Quote #3

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
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...

Last edited by Totenfluch; 07-14-2018 at 13:57.
Totenfluch is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-20-2018 , 13:19   Re: Create an entity and make it spin
Reply With Quote #4

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
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT

Last edited by scorpius2k1; 07-20-2018 at 13:20.
scorpius2k1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:27.


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