How to bindaction for input component?

#1
I create one component and code below:
void CMyComponent::Initialize()
{
Cry::DefaultComponents::CInputComponent * myinput = m_pEntity->GetOrCreateComponent<Cry::DefaultComponents::CInputComponent>();
myinput->RegisterAction("myplayer", "jump", [this](int activationMode, float value)
{
float color[] = { 1,0,0,1 };
//IRenderAuxText::Draw2dLabel(100, 350, 3, color, 1, "client:%d", 10);
gEnv->pAuxGeomRenderer->Draw2dLabel(100, 350, 3, color, 1, "client:%d", 10);
m_pEntity->SetScale(Vec3(10, 10, 10));
});
myinput->BindAction("myplayer", "jump", eAID_KeyboardMouse, EKeyId::eKI_P);
}

I Add " mycomponet" to gameobject ,then run the game, press 'P' key, the "gameobject" can not be scaled to 10, and also can't exec "Draw2dLabel" function ,why?
By the way,I use CE5.6.4.
Last edited by njw1985njw on Mon Dec 02, 2019 3:05 pm, edited 1 time in total.

Re: How to bindaction for input component?

#2
does function call? how do you know entity did not scale?

need check entity scale in update .

Cry::Entity::EventFlags CPlayerComponent::GetEventMask() const
{
return
Cry::Entity::EEvent::BecomeLocalPlayer |
Cry::Entity::EEvent::Update |
Cry::Entity::EEvent::Reset;
}

void CPlayerComponent::ProcessEvent(const SEntityEvent& event)
{
switch (event.event)
{

case Cry::Entity::EEvent::Update:
{
// printf entity scale
}
break;
}

Who is online

Users browsing this forum: No registered users and 0 guests