Hi guys,
I'm trying to spawn a coin, but it will disappear in the next tick. I'm not sure why though as it worked in the past and hoping someone here can point out my problem. Thanks.
(Pretty much should spawn a coin model that has the spinning anim that is parent to a trigger)
Code:
void SpawnCoin(const float vPos[3])
{
int Coin = CreateEntityByName("prop_dynamic");
int Trigger = CreateEntityByName("trigger_multiple");
if(IsValidEntity(Coin) && IsValidEntity(Trigger))
{
//Coin Setup
DispatchKeyValue(Coin, "model", "models/coop/challenge_coin.mdl");
SetEntPropFloat(Coin, Prop_Send, "m_flModelScale", 0.7);
DispatchSpawn(Coin);
SetVariantString("challenge_coin_idle");
AcceptEntityInput(Coin, "SetAnimation");
SetEntityRenderColor(Coin, 255, 215, 0, 255);
TeleportEntity(Coin, vPos, NULL_VECTOR, NULL_VECTOR);
//Trigger Setup
DispatchSpawn(Trigger);
ActivateEntity(Trigger);
SetEntityModel(Trigger, "models/props/cs_office/vending_machine.mdl");
TeleportEntity(Trigger, vPos, NULL_VECTOR, NULL_VECTOR);
float vMin[3], vMax[3];
for (int i = 0; i < 3; i++) {
vMin[i] = -10.0;
}
for (int i = 0; i < 3; i++) {
vMax[i] = 10.0;
}
SetEntPropVector(Trigger, Prop_Send, "m_vecMins", vMin);
SetEntPropVector(Trigger, Prop_Send, "m_vecMaxs", vMax);
SetEntPropEnt(Trigger, Prop_Send, "m_hOwnerEntity", Coin);
SetEntProp(Trigger, Prop_Send, "m_nSolidType", 2);
SetEntProp(Trigger, Prop_Send, "m_fEffects", GetEntProp(Trigger, Prop_Send, "m_fEffects") | 32);
SDKHook(Trigger, SDKHook_StartTouch, Hook_StartTouch);
}