Im trying to create an entity and animate it, i googled and found "SetAnimation" (that doesnt work), also searched for anwsers on this forum. Anyone here knows how to do it properly? (maybe my code is invalid). The model spawns properly.
Code:
int ent = CreateEntityByName("prop_dynamic");
if(ent != -1 && IsValidEntity(ent)){
DispatchKeyValue(ent, "model", mGhoul);
DispatchKeyValue(ent, "targetname", "ghoul");
float angle[3];
angle[1] = GetRandomInt(1, 360)+0.0;
DispatchKeyValue(ent, "ClassName", "ghoul");
DispatchKeyValueVector(ent, "Origin", gMonstersGhoulsSpawns[i]);
DispatchKeyValueVector(ent, "Angles", angle);
DispatchSpawn(ent);
switch(GetRandomInt(0, 2)){ // 1 of 3 anims
case 0:{
SetVariantString("ragdoll");
AcceptEntityInput(ent, "SetAnimation");
}
case 1:{
SetVariantString("testWalkN");
AcceptEntityInput(ent, "SetAnimation");
}
case 2:{
SetVariantString("Hop");
AcceptEntityInput(ent, "SetAnimation");
}
}
}
Code:
int ent = CreateEntityByName("prop_dynamic_override");
if(ent != -1 && IsValidEntity(ent)){
DispatchKeyValue(ent, "model", mGhoul);
DispatchKeyValue(ent, "targetname", "ghoul");
float angle[3];
angle[1] = GetRandomInt(1, 360)+0.0;
DispatchKeyValue(ent, "ClassName", "ghoul");
DispatchKeyValueVector(ent, "Origin", gMonstersGhoulsSpawns[i]);
DispatchKeyValueVector(ent, "Angles", angle);
ActivateEntity(ent);
DispatchSpawn(ent);
switch(GetRandomInt(0, 2)){
case 0:{
SetVariantString("ragdoll");
}
case 1:{
SetVariantString("testWalkN");
}
case 2:{
SetVariantString("Hop");
}
}
AcceptEntityInput(ent, "SetAnimation", -1, -1, 0);
AcceptEntityInput(ent, "Enable");
AcceptEntityInput(ent, "TurnOn", ent, ent, 0);
}