Raised This Month: $168 Target: $400
 42% 

[CSGO] Force Velocity on Entity


Post New Thread Reply   
 
Thread Tools Display Modes
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
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 09-13-2017 , 20:33   Re: [CSGO] Force Velocity on Entity
Reply With Quote #2

try change "prop_dynamic_override" to "prop_physics_override", I don't think you can teleport prop_dynamics by velocity, only by origin.
__________________
Github: https://github.com/Rachnus
Steam: http://steamcommunity.com/id/rachnus
_____________________________________________ _________
Taking private requests
Rachnus is offline
Vasto_Lorde
Junior Member
Join Date: Oct 2016
Old 09-14-2017 , 03:24   Re: [CSGO] Force Velocity on Entity
Reply With Quote #3

Still the same :/

I even tried this: https://forums.alliedmods.net/showthread.php?p=1899572

But the console says
Code:
ERROR!: Can't create physics object for models/witchermod/ghoul/ghoul.mdl

Last edited by Vasto_Lorde; 09-14-2017 at 04:11.
Vasto_Lorde is offline
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 09-14-2017 , 07:59   Re: [CSGO] Force Velocity on Entity
Reply With Quote #4

Try spawn a prop that works with prop_physics like a dropped C4 and make it invisible, then parent your ghoul prop onto the C4 and teleport your C4 instead of your ghoul, this is what I do here:

https://github.com/Rachnus/SuperHero...jgohan.sp#L212

I create a prop_physics with the model "models/weapons/w_ied_dropped.mdl" then parent the env_sprite to it. And the result looks like this:

https://www.youtube.com/watch?v=HKy_1t4fp_Q
__________________
Github: https://github.com/Rachnus
Steam: http://steamcommunity.com/id/rachnus
_____________________________________________ _________
Taking private requests
Rachnus is offline
Mitchell
~lick~
Join Date: Mar 2010
Location: noitacoL:
Old 09-14-2017 , 09:26   Re: [CSGO] Force Velocity on Entity
Reply With Quote #5

or just spawn it as a prop_physics_override.
__________________
Mitchell is offline
Vasto_Lorde
Junior Member
Join Date: Oct 2016
Old 09-17-2017 , 15:37   Re: [CSGO] Force Velocity on Entity
Reply With Quote #6

Quote:
Originally Posted by Rachnus View Post
Try spawn a prop that works with prop_physics like a dropped C4 and make it invisible, then parent your ghoul prop onto the C4 and teleport your C4 instead of your ghoul, this is what I do here:

https://github.com/Rachnus/SuperHero...jgohan.sp#L212

I create a prop_physics with the model "models/weapons/w_ied_dropped.mdl" then parent the env_sprite to it. And the result looks like this:

https://www.youtube.com/watch?v=HKy_1t4fp_Q
Dude you are my master. The movement works fine. But other problems occured:
1. There is a sound of C4 "moving"
2. When they fall from the edge there is a chance they flip over so we can see only feet of ghouls
3. Now my angleEntity function doesnt work, tried it on ghoul and C4 parent(and both), no results. I
Code:
stock void AngleEntity(int ent, int ent2){
	float angle[3];
	float position[3];
	float position2[3];
	GetEntPropVector(ent, Prop_Send, "m_angRotation", angle);
	GetEntPropVector(ent, Prop_Send, "m_vecOrigin", position);
	GetEntPropVector(ent2, Prop_Send, "m_vecOrigin", position2);
	
	float x = position2[0] - position[0];
	float z = position2[1] - position[1];
	float radians = ArcTangent2(z, x);
	angle[1] = radians * (180 / 3.14);
	
	SetEntPropVector(ent, Prop_Send, "m_angRotation", angle);
}
I assume that problem 1 and 2 can be solved by adding some noclip or movetype to the parent, but i dont know any DispatchKeyValue values (such as "targetname" for name)
And the problem 3 maybe could be solved by putting other model insted of C4 that can handle both angles and velocity?

I'd glady recive any kind of help from you
Vasto_Lorde is offline
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 09-18-2017 , 05:30   Re: [CSGO] Force Velocity on Entity
Reply With Quote #7

Hmm, I mean the best solution would be to have someone make your model compatible with prop_physics (I have no clue how to do this)

But...

To fix your second error, if you're passing NULL_VECTOR into the angle parameter in TeleportEntity, replace it with whatever angle you want your ghoul to have. If you are passing an angle, just keep setting angle[0] to 0.0 to keep it up straight.

You could also try change model from C4 to a barrel or something that has the same size as your ghoul.

If you want to add me, feel free.
__________________
Github: https://github.com/Rachnus
Steam: http://steamcommunity.com/id/rachnus
_____________________________________________ _________
Taking private requests
Rachnus is offline
Reply


Thread Tools
Display Modes

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


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