 |
|
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
|

07-18-2018
, 06:43
Re: Making an entity levitate and player follow it
|
#6
|
Quote:
Originally Posted by maqi
The entity won't move on it's own, you have to set it's velocity. Also do what Natsheh said, or nothing will probably work
For attaching the players:
You can try something like attach_view() to simulate what you are trying to achieve. It's a good solution, except the camera won't be movable before jumping ( seet the player origin to the plane and reset the view ). The alternative would be to match the player origin and velocity with the plane, that should work. ( not 100% sure ). Other than that you can try to set the view manually somehow or actually set the origin of a player, but i figure those would be clunky if not done properly.
Also, demonstration 10/10 
|
If you checked the code, you'd see I'm constantly changing the velocity.
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.
Quote:
Originally Posted by EFFx
I don't know what you mean with levitate, but you can just set the plane:
- Origin
- View angle (to the direction)
- And pev_velocity
For make players follow the plane, you just need set them the same vectors of the plane and set their gravity and maxspeed to 0. (can't fall and can't move inside the plane).
That's the code I'm using on my Battleground to create the plane:
PHP Code:
public createPlane()
{
new Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3]
getRandomPlaneDirection(fOrigin, fAngle, fVelocity) //the code that gets four random directions
new iEnt = fm_create_entity("info_target")
fm_create_ent
(
iEnt,
g_szClassNamesData[cTransporter],
g_szModelsData[mTransporter],
fOrigin,
fVelocity,
fAngle
) // code to create the plane
g_bPlaneSpanwed = true
g_iEnt[pPlaneTransporter] = iEnt
fOrigin[2] -= 40.0 // players under the plane.
new iPlayers[MAX_PLAYERS], iNum
get_players(iPlayers, iNum, "ach")
for(new i, id;i < iNum;i++)
{
id = iPlayers[i]
setInvisibility(id, true) // for players can't be seen by their enemies.
client_cmd(id, "spk ^"%s^"", g_szSoundsData[sTransporter]) // sound of the plane
//here are all vectors for players be able to follow the plane
set_pev(id, pev_origin, fOrigin) // Same origin of the plane
set_pev(id, pev_angles, fAngle) // Same direction of the plane
set_pev(id, pev_fixangle, 1) // Fix the angle
set_pev(id, pev_velocity, fVelocity) // Same velocity of the plane
set_pev(id, pev_gravity, 0.000001) //Can't fall
set_pev(id, pev_maxspeed, 0.000001) //Can't move
// some booleans to use later.
g_dUserData[id][bIsOnPlane] = true
g_dUserData[id][bCanUseParachute] = false
}
// to remove the plane
set_task(PLANE_REMOVE_TIME, "checkPlaneOrigin", TASK_PLANE)
}
|
Levitate = stay in air
Thanks I'll check it out
|
|
|
|