Terrain collide when moving

How to enable terrain collision when moving an object? I created an entity and script for moving (screenshot). When project starts, terrain collision works fine (entity fall on the terrain, tried in different places and Z start position). But when I started to move it with WASD it seems that collision stops working (object moves through the terrain, mountains or doesnt fall when it is in air). For PhysX there are AddLinearImpulse command which saves the collision and gravity, but as I understood its good for boxes and spheres when we need to bounce or give impulses (and for characters better to use classic physics). What commands I should use to save gravity and collision in this situation or maybe add another components? (like main character in starter game project).

You can see the example of a cowboy! It’s perfectly implemented what you’re talking about

Thank you for the reply, but I dont have any level with cowboy (only cowboy slice and he doesnt have graviity or collision, only moving and shooting when I import it). I am trying to analyze jack and his scripts and components now in terrain level (it moves exactly as I want to do). I have found movementcontrollerefx.lua script and here we have:

		LandingHeight = { default = 0.5, description = "Height at which the character will start landing.", suffix = " m" },

		FallingHeight = { default = 0.8, description = "Distance above ground that will cause a transition to falling.", suffix = " m" },
		FallingMedium = { default = 0.3, description = "How long the fall must be to trigger a medium landing.", suffix = " s" },
		FallingHard = { default = 0.5, description = "How long the fall must be to trigger a hard landing.", suffix = " s" },
		
		Radius = { default = 1.0, description = "The radius of the character's capsule for escaping infinite falling.", suffix = " m" },
		
		SlopeAngle = { default = 73.0, description = "If the ground is too steep then falling will continue [0, 90].", suffix = " deg" },

Now I am trying to find these constants in the script and understand how it works, but to no avail… It seems that they calculated Z terrain in front of entity somehow, but I’m not sure…

I have founded PhysicsComponentRequestBus.Event.AddImpulse and this exactly what I have been looking for!)

1 Like