PDA

View Full Version : How to detect entity touch with the wall, etc


hitmany
03-26-2016, 13:11
Hello!

I need to make a moving sprite which will be in contact with other solid objects. And I need to detect any touch with this entity.
This plugin for CSGO

I tried to move the sprite, but nothing helped.

I decided to use a func_rotating or a prop_physics to move the sprite with SetParent.
Now I am using func_rotating, bcs I cant stop prop_physics fall


new ball = CreateEntityByName("env_sprite_oriented");
new funcrotat = CreateEntityByName("func_rotating");
if(IsValidEntity(ball) && IsValidEntity(funcrotat))
{
new Float:Clientpos[3];
new Float:lookpos[3];
GetClientAbsOrigin(client,Clientpos);

DispatchKeyValue(ball, "model", "materials/sprites/ball.vmt");

DispatchKeyValue(ball, "spawnflags", "1");
DispatchKeyValue(ball, "rendermode", "5");

DispatchKeyValue(funcrotat, "spawnflags", "1");
DispatchKeyValue(funcrotat, "maxspeed", "180");
DispatchKeyValue(funcrotat, "rendermode", "0");
DispatchKeyValue(funcrotat, "renderfx", "0");
DispatchKeyValue(funcrotat, "rendercolor", "0 0 0");
DispatchKeyValue(funcrotat, "renderamt", "0");

//Here was the code for calculate the speed
DispatchSpawn(funcrotat);
DispatchSpawn(ball);
SetVariantString("!activator");
AcceptEntityInput(ball, "SetParent", funcrotat);
HookSingleEntityOutput(ball, "OnStartTouch", OnTouchBall);
SDKHook(funcrotat, OnTrigger, OnStartTouch);
}

public OnTouchFireball(const String:output[], caller, activator, Float:delay) //What data would be in these parameters,
{
//Not working!
}

public OnStartTouch(caller, client)
{
//Working only with player, maybe with entity
}


I saw some plugins use flashbang_projectile to detect touch with wall, maybe we have another way?

ofir753
03-26-2016, 14:15
Try use sdkhook.
SDKHook(i, SDKHook_Touch, Hook_OnTouch);

hitmany
03-26-2016, 14:26
Try use sdkhook.
SDKHook(i, SDKHook_Touch, Hook_OnTouch);
Hello, thank you! Its working only with player touch. Brush collision still undetected

hitmany
03-26-2016, 14:35
Also, I see this errors in server console

CEngineTrace::ClipRayToVPhysics : no model; bbox {0,0,0}-{0,0,0}

Full code

new ball = CreateEntityByName("env_sprite_oriented");
new funcrotat = CreateEntityByName("func_rotating");
player_ball_sprite[client] = ball;
if(IsValidEntity(ball) && IsValidEntity(funcrotat))
{
new Float:Clientpos[3];
new Float:lookpos[3];
GetClientAbsOrigin(client,Clientpos);

DispatchKeyValue(ball, "model", "materials/sprites/ball.vmt");

DispatchKeyValue(ball, "spawnflags", "1");
DispatchKeyValue(ball, "rendermode", "5");
DispatchKeyValue(funcrotat, "spawnflags", "1");
DispatchKeyValue(funcrotat, "maxspeed", "180");
DispatchKeyValue(funcrotat, "rendermode", "0");
DispatchKeyValue(funcrotat, "renderfx", "0");
DispatchKeyValue(funcrotat, "rendercolor", "0 0 0");
DispatchKeyValue(funcrotat, "renderamt", "0");

new Float:fAng[3], Float:fVel[3], Float:fPVel[3];
GetClientEyeAngles( client, fAng );
GetAngleVectors(fAng, fVel, NULL_VECTOR, NULL_VECTOR);
ScaleVector(fVel, 300.0);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", fPVel);
AddVectors(fVel, fPVel, fVel);
Clientpos[2] = Clientpos[2]+50;
DispatchSpawn(funcrotat);
DispatchSpawn(ball);
SetVariantString("!activator");
AcceptEntityInput(ball, "SetParent", funcrotat);
TeleportEntity(funcrotat, Clientpos, fAng, fVel);
HookSingleEntityOutput(funcrotat, "OnStartTouch", OnTouchball);
SDKHook(funcrotat, SDKHook_Touch, OnStartTouch);
}

public OnTouchball(const String:output[], caller, activator, Float:delay) //What data would be in these parameters,
{
PrintToChatAll("touch");
}

public OnStartTouch(caller, client)
{
PrintToChatAll("touch2")
}

hitmany
03-26-2016, 14:42
And touch working with player only with this, but still cant detect brush collusion

SetEntProp(funcrotat, Prop_Send, "m_usSolidFlags", 0x0008);
SetEntProp(funcrotat, Prop_Data, "m_nSolidType", 2);
SetEntProp(funcrotat, Prop_Send, "m_CollisionGroup", 2);

hitmany
03-26-2016, 15:33
Its working great with smokegrenade_projectile
But I cant disable gravitation

hitmany
03-26-2016, 15:42
SetEntityMoveType(funcrotat, MOVETYPE_FLY); is working))
Thread closed