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

Solved Making an entity levitate and player follow it


Post New Thread Reply   
 
Thread Tools Display Modes
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-18-2018 , 08:37   Re: Making an entity levitate and player follow it
Reply With Quote #11

Quote:
Originally Posted by KliPPy View Post
You aren't changing it though. velocity_by_aim doesn't set the velocity.
What a silly mistake

Quote:
Originally Posted by KliPPy View Post
Also to change entity's (and player's) position use EngFunc_SetOrigin, not pev_origin.
Why?
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-18-2018 , 08:38   Re: Making an entity levitate and player follow it
Reply With Quote #12

Quote:
Originally Posted by edon1337 View Post
Why?
EngFunc_SetOrigin doesn't just set the origin, it does some other stuff that the physics system needs. While changing pev_origin may work in some cases, the former is the safest bet.
__________________
klippy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-18-2018 , 08:40   Re: Making an entity levitate and player follow it
Reply With Quote #13

Quote:
Originally Posted by KliPPy View Post
EngFunc_SetOrigin doesn't just set the origin, it does some other stuff that the physics system needs. While changing pev_origin may work in some cases, the former is the safest bet.
Okay thanks!
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-18-2018 , 10:21   Re: Making an entity levitate and player follow it
Reply With Quote #14

Quote:
Originally Posted by edon1337 View Post
If you checked the code, you'd see I'm constantly changing the velocity.
I checked the code and as you probably figured by now, you did no such thing back then.

Quote:
Originally Posted by edon1337 View Post
I don't need to attach the view, I need to attach the entire entity.
Again, if you checked the code you'd see I'm settings players' origin at plane's origin.
Again, i checked the code, just gave you an alternative solution that produces the same/similar result in a different way.

No need for these kind of responses when im only trying to help and you were also wrong to answer like that.

Anyway, did you make it ?
__________________
stuff

Last edited by maqi; 07-18-2018 at 10:21.
maqi is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-18-2018 , 10:44   Re: Making an entity levitate and player follow it
Reply With Quote #15

Quote:
Originally Posted by maqi View Post
I checked the code and as you probably figured by now, you did no such thing back then.
But I never edited my code?

Quote:
Originally Posted by maqi View Post
No need for these kind of responses when im only trying to help and you were also wrong to answer like that.
What kind of response? What was I wrong about? I don't get it.

Quote:
Originally Posted by maqi View Post
Anyway, did you make it ?
Nope, but I'm still working on it

Last edited by edon1337; 07-18-2018 at 10:47.
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-18-2018 , 11:30   Re: Making an entity levitate and player follow it
Reply With Quote #16

You were talking to me like im some random spammer insisting that I didn't read even the code. While, in fact I read the code and in no point in it did you set the velocity like you said. That is where you were wrong.

It's off topic anyway. Just thought i should clarify.
__________________
stuff

Last edited by maqi; 07-18-2018 at 11:30.
maqi is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-18-2018 , 11:32   Re: Making an entity levitate and player follow it
Reply With Quote #17

Quote:
Originally Posted by maqi View Post
You were talking to me like im some random spammer insisting that I didn't read even the code. While, in fact I read the code and in no point in it did you set the velocity like you said. That is where you were wrong.

It's off topic anyway. Just thought i should clarify.
I'm sorry if I offended you, didn't mean it that way


What velocity am I supposed to give the entity so it can keep going forever?

This makes the plane go in the wrong direction, it should go straight forward
PHP Code:
MakeAirPlane( )
{  
    new 
Float:fOrigin] = { 3734.9, -23.83295.2 };
    new 
Float:fAngle] = { -20.5, -170.90.0 };
    new 
Float:fVelocity];
    
    
g_iAirPlaneEnt create_entity"info_target" );
    
    
set_pevg_iAirPlaneEntpev_classnameAIRPLANE_CLASSNAME );
    
engfuncEngFunc_SetModelg_iAirPlaneEntg_iDataAirPlaneAirPlane_Model ] );
    
set_pevg_iAirPlaneEntpev_solidSOLID_BBOX );
    
set_pevg_iAirPlaneEntpev_movetypeMOVETYPE_FLY );
    
engfuncEngFunc_SetOriging_iAirPlaneEntfOrigin );
    
    
velocity_by_aimg_iAirPlaneEnt2000fVelocity );
    
set_pevg_iAirPlaneEntpev_velocityfVelocity );
    
    
fOrigin] -= 40.0;
    
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"ch" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
        
AttachPlayerToPlaneiTempIDfOriginfAnglefVelocity );
    }
}

AttachPlayerToPlaneidFloat:fOrigin], Float:fAngle], Float:fVelocity] )
{
    
set_user_renderingidkRenderFxGlowShell000kRenderTransAlpha);
    
    
engfuncEngFunc_SetOriginidfOrigin );
    
set_pevidpev_anglesfAngle );
    
set_pevidpev_fixangle);
    
set_pevidpev_velocityfVelocity );
    
set_pevidpev_gravity0.000001 );
    
set_pevidpev_maxspeed0.000001 );
    
    
g_bIsPlayerInParachuteid ] = false;
    
g_bPlayerInPlaneid ] = true;


Last edited by edon1337; 07-18-2018 at 11:32.
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-18-2018 , 11:47   Re: Making an entity levitate and player follow it
Reply With Quote #18

With MOVETYPE_FLY the entity with velocity should move forever, untill killed.

Also velocity_by_aim should throw an error in your case, it's used to calculate the velocity in the direction the PLAYER is looking.
__________________
stuff
maqi is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 07-18-2018 , 14:42   Re: Making an entity levitate and player follow it
Reply With Quote #19

My stock to four random directions (Map must be de_mon)

PHP Code:
getRandomPlaneDirection(Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3])
{
    switch(
random_num(03))
    {
        case 
0:
        {
            
fOrigin[0] = 3983.9
            fOrigin
[1] = -3983.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.6
            fAngle
[1] = 133.5
            fAngle
[2] = 0.0
            
            fVelocity
[0] = -206.6
            fVelocity
[1] = 217.2
            fVelocity
[2] = -10.6
        
}
        case 
1:
        {
            
fOrigin[0] = -3983.9
            fOrigin
[1] = -3983.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.3
            fAngle
[1] = 38.6
            fAngle
[2] = 0.0
            
            fVelocity
[0] = 234.3
            fVelocity
[1] = 187.2
            fVelocity
[2] = -5.1
        
}
        case 
2:
        {
            
fOrigin[0] = -3279.9
            fOrigin
[1] = 1975.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.2
            fAngle
[1] = -36.3
            fAngle
[2] = 0.0
            
            fVelocity
[0] = 241.5
            fVelocity
[1] = -177.8
            fVelocity
[2] = -3.3
        
}
        case 
3:
        {
            
fOrigin[0] = 3205.4
            fOrigin
[1] = 2055.4
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.5
            fAngle
[1] = -138.9
            fAngle
[2] = 0.0
            
            fVelocity
[0] = -226.0
            fVelocity
[1] = -197.0
            fVelocity
[2] = -9.1
        
}
    }

So, at MakeAirPlane(), you should just do

PHP Code:
new Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3]
getRandomPlaneDirection(fOriginfAnglefVelocity
And it'll generate a direction.

So, what you needed to create the plane correctly was:

- Origin = Where the plane will be created
- Angle = The direction
- Velocity = To set the velocity, I used that code to get those vectors:

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

#define PLUGIN "Print Point vector"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("aa""cmdPrint")
}

public 
cmdPrint(id)
{
    new 
Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3]
    
pev(idpev_originfOrigin)
    
pev(idpev_anglesfAngle)
    
velocity_by_aim(id300fVelocity// 300 is the velocity.
    
    
server_print("fOrigin[0] = %.1f^n^nfOrigin[1] = %.1f^n^nfOrigin[2] = %.1f"fOrigin[0], fOrigin[1], fOrigin[2])
    
server_print("fAngle[0] = %.1f^n^nfAngle[1] = %.1f^n^nfAngle[2] = %.1f"fAngle[0], fAngle[1], fAngle[2])
    
server_print("fVelocity[0] = %.1f^n^nfVelocity[1] = %.1f^n^nfVelocity[2] = %.1f"fVelocity[0], fVelocity[1], fVelocity[2])

I just used sv_gravity 0, gone to the sky and typed 'aa' on console and got all the point's vectors.

And what you needed to make players follow the plane:

- Set the same vectors but with some different stuff:

1. pev_fixangle = to fix the player's angle
2. Set gravity 0 = so the player can not fall.
3. Set maxspeed to 0 = so the player can not move while he's in the plane.


Also,

PHP Code:
get_playersszPlayersiNum"ch" 
You must use the 'a' flag too.

You should know that is possible players jump from the plane at the same time and be stuck with each other, you can avoid it by setting their solid type to SOLID_NOT and after some time from the plane's jump, you can set the default solid type back.

You can maybe set the plane's solid type to SOLID_NOT too, so he has immunity to stuck in something. Also, add a time to auto-drop players that didn't jump from the plane while he was flying through the sky and remove it.


This is what i'm doing here, you can take these or make your version based in what I said.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 07-18-2018 at 14:56.
EFFx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-18-2018 , 19:18   Re: Making an entity levitate and player follow it
Reply With Quote #20

Quote:
Originally Posted by EFFx View Post
My stock to four random directions (Map must be de_mon)

PHP Code:
getRandomPlaneDirection(Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3])
{
    switch(
random_num(03))
    {
        case 
0:
        {
            
fOrigin[0] = 3983.9
            fOrigin
[1] = -3983.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.6
            fAngle
[1] = 133.5
            fAngle
[2] = 0.0
            
            fVelocity
[0] = -206.6
            fVelocity
[1] = 217.2
            fVelocity
[2] = -10.6
        
}
        case 
1:
        {
            
fOrigin[0] = -3983.9
            fOrigin
[1] = -3983.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.3
            fAngle
[1] = 38.6
            fAngle
[2] = 0.0
            
            fVelocity
[0] = 234.3
            fVelocity
[1] = 187.2
            fVelocity
[2] = -5.1
        
}
        case 
2:
        {
            
fOrigin[0] = -3279.9
            fOrigin
[1] = 1975.9
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.2
            fAngle
[1] = -36.3
            fAngle
[2] = 0.0
            
            fVelocity
[0] = 241.5
            fVelocity
[1] = -177.8
            fVelocity
[2] = -3.3
        
}
        case 
3:
        {
            
fOrigin[0] = 3205.4
            fOrigin
[1] = 2055.4
            fOrigin
[2] = 3931.9
            
            fAngle
[0] = -0.5
            fAngle
[1] = -138.9
            fAngle
[2] = 0.0
            
            fVelocity
[0] = -226.0
            fVelocity
[1] = -197.0
            fVelocity
[2] = -9.1
        
}
    }

So, at MakeAirPlane(), you should just do

PHP Code:
new Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3]
getRandomPlaneDirection(fOriginfAnglefVelocity
And it'll generate a direction.

So, what you needed to create the plane correctly was:

- Origin = Where the plane will be created
- Angle = The direction
- Velocity = To set the velocity, I used that code to get those vectors:

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

#define PLUGIN "Print Point vector"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("aa""cmdPrint")
}

public 
cmdPrint(id)
{
    new 
Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3]
    
pev(idpev_originfOrigin)
    
pev(idpev_anglesfAngle)
    
velocity_by_aim(id300fVelocity// 300 is the velocity.
    
    
server_print("fOrigin[0] = %.1f^n^nfOrigin[1] = %.1f^n^nfOrigin[2] = %.1f"fOrigin[0], fOrigin[1], fOrigin[2])
    
server_print("fAngle[0] = %.1f^n^nfAngle[1] = %.1f^n^nfAngle[2] = %.1f"fAngle[0], fAngle[1], fAngle[2])
    
server_print("fVelocity[0] = %.1f^n^nfVelocity[1] = %.1f^n^nfVelocity[2] = %.1f"fVelocity[0], fVelocity[1], fVelocity[2])

I just used sv_gravity 0, gone to the sky and typed 'aa' on console and got all the point's vectors.

And what you needed to make players follow the plane:

- Set the same vectors but with some different stuff:

1. pev_fixangle = to fix the player's angle
2. Set gravity 0 = so the player can not fall.
3. Set maxspeed to 0 = so the player can not move while he's in the plane.


Also,

PHP Code:
get_playersszPlayersiNum"ch" 
You must use the 'a' flag too.

You should know that is possible players jump from the plane at the same time and be stuck with each other, you can avoid it by setting their solid type to SOLID_NOT and after some time from the plane's jump, you can set the default solid type back.

You can maybe set the plane's solid type to SOLID_NOT too, so he has immunity to stuck in something. Also, add a time to auto-drop players that didn't jump from the plane while he was flying through the sky and remove it.


This is what i'm doing here, you can take these or make your version based in what I said.
Thanks
edon1337 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 03:54.


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