[solved] 1.17 to 1.18: camera does not move anymore

Hello,

I have an RTS camera component derived from some of the examples found here and in Oleksandr’s book. It works well with 1.17 but with 1.20 the camera/player does not move.

I can see that all the input and tick events fire normally. The OnTick() method looks like this:

void RTSCameraComponent::OnTick(float deltaTime, AZ::ScriptTimePoint time)
{
AZ::Transform entityTransform;
AZ::TransformBus::EventResult(entityTransform, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);

float x = 0.f;
float y = 0.f;
float z = 0.f;

// ... set x,y,z as needed...

if (y != 0.f || x != 0.f || z != 0.f)
   {
    auto new_position = entityTransform.GetPosition() + AZ::Quaternion::CreateRotationZ(currentRotation) * AZ::Vector3{x, y, z};
    entityTransform.SetPosition(new_position);

    AZ::TransformBus::Event(GetEntityId(), &AZ::TransformBus::Events::SetWorldTM, entityTransform); 
    }
}

The resulting behavior in 1.20 only is exactly as if the SetWorldTM event is not sent. The component hierarchy is:

player (RTSCameraComponent)
`-- camera (Camera)

Separetely I have another FPS camera example that’s directly from the PlayerControlsComponent in Part 8 of Olek’s book - though the older 1.17 version that uses CryPhysics - and that does work in both 1.17 and 1.20. That OnTick() looks like this:

void PlayerControlsComponent::OnTick(float dt, AZ::ScriptTimePoint)
{
static const Vector3 yUnit = Vector3::CreateAxisY(1.f);
static const Vector3 xUnit = Vector3::CreateAxisX(1.f);
// Figure out where the movement will take the entity
AZ::Vector3 direction{0, 0, 0};

// ... set direction as needed ...

// Issue character move command
using namespace LmbrCentral;
CryCharacterPhysicsRequestBus::Event(GetEntityId(),
    &CryCharacterPhysicsRequestBus::Events::RequestVelocity,
    direction, 0);
} 

The entity hierarchy is similar but the player has a physics component:

player (PlayerControlsComponent, CharacterPhysics)
`-- Camera
      `-- Local camera (Camera)

I’m guessing that the change has to do with the PhysX changes in 1.20. Does SetWorldTM work as before or what is now the preferred way of moving a camera without physics?

Thanks!

Hi! my old simple fps camera work just fine, even with v1.2
you may take a look on code here

h https://pastebin.com/mn37sdvf
cpp https://pastebin.com/AkpyUf8a

component uses only entity’s transforms.

Hi Fluffy!

Thanks for your suggestion. I switched to using m_entity->GetTransform() and m_entity->SetTransform() instead of using AZ::TransformBus as you do but unfortunately so far the result is the same: it works with1.17 but not with 1.20.

To try and narrow this down I built with 1.18 which I had skipped before. The same thing happens: no movement. So it looks like the change is introduced by that version somehow.

It’s unlikely this is coming a core code change directly, SetWorldTM or SetTransform are obviously working at large. I minimized the number of gems but that made no difference. What else could be causing it?

I think no, try to check this option on entity’s transforms


coz static flag do not allow move entity

No dice. Static is unchecked, and flipping it back and forth does not help. But thanks again for suggesting.

Time permitting I’ll try to package this into a minimal gem and upload here.

While preparing the minimal repro case I figured this out:

  1. I attached the component a basic shape in the Simple level and it worked. That ruled out regression in the engine and pointed to a problem in my project.

  2. Looking into the project, I tried deleting another player entity that I have around and that is used to switch to an FPS perspective and that fixed the issue. That entity is normally disabled at the top level but now that is not sufficient, it’s local camera must be disabled as well for the other’s movement to work.

I’m not clear on the root cause. Both the RTS and FTS entities process input so perhaps some kind of priority / order change starting starting in 1.18.

Either ways look solved. Thanks for your help @fluffy!

Try using new physics bus system. Meaning add the physX or physics bus and use it too raycast. Perhaps its not able too move because they using old phys cry engine for UI for mouse clicks. Think actor gem needs the mod if ur doing it via animated actor character vs staticmesh on tm bus. But I need too find vs github code and maybe compile ur code. I start on .18 and got lumberyardtutor .me tutorial working