Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Sphere collision produces inconsistent results based on input

I'm trying to replicate Cities:Skylines camera controls and behavior. Here is my actor setup:

     RootSphere = CreateDefaultSubobject<USphereComponent>(TEXT("Root"));
     RootComponent = RootSphere;
     RootSphere->BodyInstance.bLockXRotation = true;
     RootSphere->BodyInstance.bLockYRotation = true;
     RootSphere->BodyInstance.bLockZRotation = true;
     // Other components

"CameraPawn" profile was made by me and it only blocks WorldStatic and does nothing else. Then I wrote the following code inside Tick:

         FVector Movement = FVector(MovementInput /* FVector2D */, 0) * DeltaTime * Speed;
         Movement = CurrentCameraAngle.RotateVector(Movement);

This properly prevented the actor from going through simple flat landscape. However, in C:S you can also zoom using the mouse wheel and I tried to replicate the same thing:

         const float Input = ZoomingInput * ZoomMultipler;
         const FVector Direction = CurrentCameraAngle.Vector();
         AddActorWorldOffset(Direction * Input);

This works as expected with exception of that it passes though the landscape. I've tried many things - enabling sweeping, ccd, collision thickness on landscape, batching AddActorWorldOffset calls together - nothing helps. The physics engine seems to completely ignore second approach to modifying position.

Also the steps aren't even big enough to just "jump" through the landscape - it is possible to stop at a point where the sphere is half above, half below/inside the landscape and the engine still doesn't attempt to force it away. Also this problem appears only when moving directly down - "zooming" at angle properly triggers blocking collision. Also sometimes colliding with landscape by zooming causes the actor to endlessly fly upwards...

I'm completely lost - any suggestions are welcome

P.S. I've omitted most of actor code for sake of question brevity but I'm sure that it works correctly. I can post it if it's needed

Product Version: UE 4.19
more ▼

asked Jun 25 '18 at 12:01 AM in C++ Programming

avatar image

1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question