Raised This Month: $32 Target: $400
 8% 

Spinning an entity in radius


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r14170
Veteran Member
Join Date: Dec 2009
Old 08-22-2011 , 18:04   Spinning an entity in radius
Reply With Quote #1

How do i spin an entity around me in radius of some units?
r14170 is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-22-2011 , 18:51   Re: Spinning an entity in radius
Reply With Quote #2

Well, if it's a point entity and you really must rotate it the hard way, there are alot of calculations to do which I don't have experience in... however, if the sole purpose of that entity is to orbit a player, you can make the model of that entity offset from the center and then just place the entity in the middle of the player and apply rotation velocity, that will make it look like it's orbiting.
__________________
Hunter-Digital is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-22-2011 , 19:06   Re: Spinning an entity in radius
Reply With Quote #3

Quote:
Originally Posted by Hunter-Digital View Post
if it's a point entity and you really must rotate it the hard way
Here's some example code for that.

Note that you should use a different think method (such as register_think()) as it would be more efficient than FM_Think.
FM_Think was only used in this example to be generic enough so you could understand the idea.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>

#define SPECIAL_ROTATE_VALUE 3761571

public plugin_init() {
    
register_forward(FM_Think"FwdThink");
}

public 
FwdThink(ent) {
    if(
pev(entpev_iuser4) == SPECIAL_ROTATE_VALUE) {
        new 
Float:center[3];
        
pev(entpev_vuser4center);
        
        new 
Float:radiusFloat:rps;
        
pev(entpev_fuser3radius);
        
pev(entpev_fuser4rps);
        
        new 
Float:degrees;
        
pev(entpev_fuser2degrees);
        
        if(++
degrees 180.0) {
            
degrees -= 360.0;
        }
        
        new 
Float:angle[3];
        
angle[1] = degrees;
        
        
angle_vector(angleANGLEVECTOR_FORWARDangle);
        
        
xs_vec_mul_scalar(angleradius vector_length(angle), angle);
        
xs_vec_add(anglecenterangle);
        
        
engfunc(EngFunc_SetOriginentangle);
        
        
set_pev(entpev_fuser2degrees);
        
        
set_pev(entpev_nextthinkget_gametime() + (1.0 rps 360.0));
    }
}

// rps = rotations per second
StartRotate(entFloat:center[3], Float:radiusFloat:rps) {
    
set_pev(entpev_iuser4SPECIAL_ROTATE_VALUE);
    
    
set_pev(entpev_vuser4center);
    
set_pev(entpev_fuser3radius);
    
set_pev(entpev_fuser4rps);
    
    
set_pev(entpev_fuser20.0); // set initial degrees to 0
    
    
set_pev(entpev_nextthinkget_gametime());

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-23-2011 , 10:11   Re: Spinning an entity in radius
Reply With Quote #4

In this case, you have to consider renaming
PHP Code:
new Float:degrees
to something different, because its predefined in xs and float includes.
SpeeDeeR is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-24-2011 , 19:25   Re: Spinning an entity in radius
Reply With Quote #5

hm interesting.
can I rotate a rocket with this code while it moving in the air ?
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-24-2011 , 19:26   Re: Spinning an entity in radius
Reply With Quote #6

Yes. You would have to calculate the angles based on the certain degree angle.
Angle calculations for the model may vary by the model being used.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 12:19.


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