I had a question, I’m making a TPS and the movement is similar to that of Fortnite, I would like to know if there is an optimal way to obtain the speed that it uses to go forward, backward, right and left to make the animations since in them the character does not turn to where he moves, but always looks towards the forward of the camera.
Hello @gerim9999,
I assume you’re looking to implement a directional speed modifier. To achieve this, refer to this forum post.
It uses the dot product between the character’s forward vector and the movement direction. This value is then used to determine the resulting speed modifier (ranging from 0 to 1), which adjusts the character’s final speed accordingly.
Is there a way to modify the capsule collider to work in the Z axis either by rotating it or increasing the length along the Z axis?
I’m curious on how you would implement grappling hook system? I’ve seen videos on youtube using spring joints but it doesn’t seem to work on ECM2
While the capsule can be rotated as desired, it has been designed primarily for vertical characters (e.g., humanoids). This means that the bottom area of the capsule (i.e., the “feet”) remains fixed even when the capsule is rotated. For example, when a player lies down (prones), their feet are still considered to be their feet in terms of the capsule’s orientation. This behavior can cause ground detection to not function as expected. To address this, the suggested approach is to either treat proning as a modified crouch or implement a custom movement mode (similar to flying) that properly supports the rotated capsule.
You can use the same approach; however, for your “end point,” you will need an additional rigidbody and attach the character to this end point instead of attaching the joint to the character directly.
To achieve this, you can use the CharacterMovement.AttachTo
method. Additionally, ensure that impartPlatformMovement
, impartPlatformRotation
, and impartPlatformVelocity
are enabled.
Yeah, I just wanna change the orientation or shape of the collider without altering the movement so the feet would still remain at the bottom when the player is lying down but I have no idea how.
I’ve seemed to make some progress but it’s still behaving a bit odd. Any ideas?
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out RaycastHit hit, maxDistance, grappleLayer))
{
hitPoint = hit.point;
isGrappling = true;
// Instantiate placeholder at the player's current position
placeholder = Instantiate(placeholderPrefab, player.position, Quaternion.identity);
Rigidbody placeholderRigidbody = placeholder.GetComponent<Rigidbody>();
if (placeholderRigidbody == null)
{
Debug.LogError("Placeholder prefab must have a Rigidbody component!");
return;
}
// Create SpringJoint on the placeholder
springJoint = placeholder.AddComponent<SpringJoint>();
springJoint.autoConfigureConnectedAnchor = false;
springJoint.connectedAnchor = hitPoint;
springJoint.spring = spring;
springJoint.damper = damper;
springJoint.massScale = massScale;
float distance = Vector3.Distance(player.position, hitPoint);
springJoint.maxDistance = distance * 0.8f;
springJoint.minDistance = distance * 0.25f;
// Attach the character to the placeholder's Rigidbody
characterMovement.AttachTo(placeholderRigidbody);
// Enable line renderer
lineRenderer.positionCount = 2;
lineRenderer.SetPosition(0, player.position);
lineRenderer.SetPosition(1, hitPoint);
}
Hello again! I hope you are well!
I’m implementing ECM2 for my animal and creature AIs. Due to the 4 legged nature of these characters, it’s very noticable when one is on a slope - the character is not aligned to the slope, so it’s legs are both hanging in the air and embedded in the terrain:
I created a new component,
AlignToSlope
, that sets the transform to align the “up” rotation with the slope in the Update
method. However, this causes the animal to “jitter”, suggesting it’s competing with some other method that’s modifying the transform.
Is there any such slope alignment functionality within ECM2, to handle “long” character models such as animals?
EDIT: I’m using Root Motion (RootMotionController
) if that’s relevant.
Many thanks again!
Hi @Evar155,
Yes, that’s the downside of treating prone as crouch—the model will clip. A more robust solution would involve implementing a custom movement mode, similar to the flying movement mode, to account for the new capsule orientation.
Hi @dev_nex,
Could you provide more details about the issue you’re encountering? Additionally, you could try disabling the Character and switching from a Kinematic to a Dynamic Rigidbody while grappling, then reverting to the regular character (Kinematic) for standard mechanics.
Hi @mroshaw,
Yes, ECM2 already includes an additional component designed to smoothly align the character with the terrain slope. It can be configured to sample an area and use the average normal as the “terrain” normal, which may help resolve your current issue.
You can find this feature in the Examples → Orient to Ground example.
Amazing, thank you!
Hi there. I need help with NavMesh Character script. I want to create AI that walk around the map. I did follow the documentation but with that MoveToDestination method, my character runs toward the target. Is there any possibility to make him walk to the destination and not run or sprint?