Using custom collision channels solved our problem:
Answer here:
https://forums.unrealengine.com/show...forms&p=189343
Thanks to BadderThanBad for pointing me in the right direction.
Announcement
Collapse
No announcement yet.
Add Force
Collapse
X
-
The Britain repliedI got it working, and I will be posting a tutorial here soon. Thank you all for your help.
Leave a comment:
-
The Britain repliedOriginally posted by SmittyJ View PostShouldn't it be * DeltaTime instead of /?
Leave a comment:
-
The Britain repliedOriginally posted by BlackRang666 View PostIt doesn't even slow down? Maybe you should add force to the movement component instead? IDK.
Code:CharacterMovement->AddForce(FVector(0, 0, (-1 * (GetVelocity().Z / DeltaSeconds)) * CapsuleComponent->GetMass()));
Leave a comment:
-
BlackFangTech repliedIt doesn't even slow down? Maybe you should add force to the movement component instead? IDK.
Leave a comment:
-
The Britain repliedOriginally posted by BlackRang666 View PostForce = mass * acceleration. Acceleration = change in velocity / time. In your case, acceleration = -1*velocity.z / deltatime. Force = acceleration * mass. SO... You need to multiply what you have with the character's mass and deltatime. Using gravity wouldn't work because it would only stop gravity, but you would still keep falling at the same speed as when gravity was turned off.
Code:CapsuleComponent->AddForceAtLocation(FVector(0, 0, (-1 * (GetVelocity().Z / DeltaSeconds)) * CapsuleComponent->GetMass()), GetActorLocation());
I tried AddForce as well:
Code:CapsuleComponent->AddForce(FVector(0, 0, (-1 * (GetVelocity().Z / DeltaSeconds)) * CapsuleComponent->GetMass()));
Last edited by The Britain; 12-06-2014, 11:22 PM.
Leave a comment:
-
BlackFangTech repliedForce = mass * acceleration. Acceleration = change in velocity / time. In your case, acceleration = -1*velocity.z / deltatime. Force = acceleration * mass. SO... You need to multiply what you have with the character's mass and deltatime. Using gravity wouldn't work because it would only stop gravity, but you would still keep falling at the same speed as when gravity was turned off.
Leave a comment:
-
The Britain repliedOriginally posted by tegleg View Postshouldnt it be GlobalGravityZ * character mass or something like thatCode:CapsuleComponent->AddForceAtLocation(FVector(0, 0, (GetWorld()->GetGravityZ() * CapsuleComponent->GetMass()) * -1), GetActorLocation());
Leave a comment:
-
tegleg repliedshouldnt it be GlobalGravityZ * character mass or something like that
Leave a comment:
-
The Britain started a topic Add ForceAdd Force
I have a weird problem that needs an equally weird solution. Basically, I am trying to have my player land on a platform while retaining 'overlap all' for the player and the platform (Paper2D, but shouldn't matter).
Code:CapsuleComponent->AddForceAtLocation(FVector(0, 0, GetVelocity().Z * -1), GetActorLocation());
I asked a similar question on the answer hub: https://answers.unrealengine.com/que...-question.html
Code:void ATestPlatCharacter::Tick(float DeltaSeconds){ Super::Tick(DeltaSeconds); GEngine->ClearOnScreenDebugMessages(); FVector coords = GetActorLocation(); x = coords.X; z = coords.Z; depth = coords.Y; if (place_meeting<APlatformParent>(x,z - 1)) { free = 0; } else { free = 1; } if (free == 0) { /* Does not work. */ //CapsuleComponent->SetEnableGravity(false); //CapsuleComponent->AddImpulseAtLocation(FVector(0, 0, GetVelocity().Z * -1), GetActorLocation()); //CapsuleComponent->AddForceAtLocation(FVector(0, 0, GetVelocity().Z * -1), GetActorLocation()); //CapsuleComponent->ComponentVelocity = FVector(0, 0, 0); //CapsuleComponent->SetEnableGravity(false); //bSimGravityDisabled = true; /* Kinda works but doesnt'. */ //CharacterMovement->Velocity = FVector(0, 0, 0); //CharacterMovement->Velocity.Z = 0; /* This tries to work, but then there is no friction. Perhaps compensate? */ //CharacterMovement->GravityScale = 0.0f; //CharacterMovement->Velocity.Z = 0; CapsuleComponent->AddForceAtLocation(FVector(0, 0, GetVelocity().Z * -1), GetActorLocation()); } else { //The character is not on the ground. } GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::SanitizeFloat(GetVelocity().Z)); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString("free = ") + FString::FromInt(free)); }
Tags: None
Leave a comment: