x

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"

What is causing my velocity/ acceleration to differ from control rotation?

I have a round world. So I'm converting the character movement component to allow for this. I use

 FTransform compToWorldTrans = CharacterOwner->GetCapsuleComponent()->GetComponentTransform();
     FVector rotatedVector = compToWorldTrans.InverseTransformVectorNoScale(VectorToConvert);
     return rotatedVector;

to give me the unrotated vector to compare against throughout the CMP. Alternatively I use

 FTransform compToWorldTrans = CharacterOwner->GetCapsuleComponent()->GetComponentTransform();
     FVector rotatedVector = compToWorldTrans.TransformVectorNoScale(VectorToConvert);
     return rotatedVector;

to give me the rotated vector for gravity and similar logic. On my character class on the tick function I adjust the characters control rotation so that the down vector of the capsule always points toward the planet center like so

 FRotator addInRot = FRotator(0, mouseX, 0);
     FRotator correctRot = FRotationMatrix::MakeFromZX(GetCapsuleComponent()->GetComponentLocation(), GetCapsuleComponent()->GetForwardVector()).Rotator();
     FQuat testQuat = correctRot.Quaternion() * addInRot.Quaternion();
     Controller->SetControlRotation(testQuat.Rotator());

Yet when I move my character around in the world I can see the velocity vector and acceleration vector start to diverge from the control rotation forward vector. You can see this in the screen shot. The screen grab shows the character moving "forward" or pressing the "w" key. The velocity and acceleration should point in the same vector as the control rotation. Now there's a lot inside the CMP so I could have missed something but I'm trying to narrow down where this is occurring at. Is it a result of the control rotation in my character class being incorrect? Am I adding those rotations together the wrong way? The blue line appears to be correct to me. So I'm guessing it's somewhere in the CMP, but for the life of me I cannot figure out where.

alt text

Product Version: UE 4.10
Tags:
vector.jpg (49.6 kB)
more ▼

asked Jul 01 '16 at 01:59 PM in C++ Programming

avatar image

Thumper
966 139 149 388

avatar image Thumper Jul 01 '16 at 03:33 PM

One thing is for certain the character control rotation is wrong. I stumble into gimbal lock and the character turns over on its head. I had this setup a while back through Blueprints but it seems I'm not doing it the same way in code. It works until I get to the poles of the world and then the character starts to fall over.

(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