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

[CSGO] Force Velocity on Entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Vasto_Lorde
Junior Member
Join Date: Oct 2016
Old 09-13-2017 , 19:08   [CSGO] Force Velocity on Entity
Reply With Quote #1

So i have this Entity that i want to move by velocity
This is how i create it:
Code:
int ent = CreateEntityByName("prop_dynamic_override");
if(ent != -1 && IsValidEntity(ent)){
	float angle[3];
	angle[1] = GetRandomInt(1, 360)+0.0;
	
	DispatchKeyValue(ent, "model", mGhoul);
	DispatchKeyValue(ent, "Targetname", "ghoul");
	DispatchKeyValue(ent, "Classname", "ghoul");
	DispatchKeyValueVector(ent, "Origin", gMonstersGhoulsSpawns[i]);
	DispatchKeyValueVector(ent, "Angles", angle);
	
	ActivateEntity(ent);
	bool didit = DispatchSpawn(ent);
	
	if(didit){
		SetEntProp(ent, Prop_Send, "m_nSequence", GHOUL_RUNBACK);
		
		SetEntPropString(ent, Prop_Send, "m_iName", "ghoul");
		
		SetEntPropFloat(ent, Prop_Send, "m_flPlaybackRate", 1.0);
		
		CreateTimer(0.1, GhoulThink, i);
	}
}
And the GhoulThink sets the entity velocity like that:
Code:
stock void MoveEntity(int ent, int ent2, float speed){
	float velocity[3];
	float position[3];
	float position2[3];
	GetEntPropVector(ent, Prop_Send, "m_vecOrigin", position);
	GetEntPropVector(ent2, Prop_Send, "m_vecOrigin", position2);
	
	float distance;
	distance=GetEntitiesDistance(ent, ent2);
	
	float time = distance / speed;
	velocity[0] = 100.0;//(position2[0] - position[0]) / time;
	velocity[1] = 100.0;//(position2[1] - position[1]) / time;
	velocity[2] = 100.0;//(position2[2] - position[2]) / time;
	
	TeleportEntity(ent, NULL_VECTOR, NULL_VECTOR, velocity); //4 types of setting velocity
	SetEntPropVector(ent, Prop_Data, "m_vecVelocity", velocity);
	SetEntPropVector(ent, Prop_Data, "m_vecBaseVelocity", velocity);
	SetEntPropVector(ent, Prop_Data, "m_vecAbsVelocity", velocity);
}
The problem is, wheter i set const velocity or use one of 4 ways to set velocity, the entity doesn't move. There is no console errors, every piece of code is working fine. What am I doing wrong here?

PS. changing Prop_Data to Prop_Send only gives me this (Same for all m_vecs):
Code:
Exception reported: Property "m_vecAbsVelocity" not found (entity 88/ghoul)
Vasto_Lorde is offline
 



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 22:25.


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