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"

AddForce in TickComponent won't work

Hey guys, I have again a big problem. I wanted to implement a new gravity system for all physical objects... so far as I know are there FBodyInstance and UPrimitiveComponent. I do change some Engine Source code for a better implementation of this. Because that FBodyInstance has no way to interact with the UWorld where all objects with mass are stored, to calculate the local mass of an FBodyInstance, so I use UPrimitiveComponent to add the gravity force every Tick, but this doesn't work, also adding any velocity doesn't do anything!

I use this added function to add the force (the debugger said the runtime comes to that point):

 void UPrimitiveComponent::TickComponent(float deltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) {
     this->AddForce(FVector(1000, 0, 0) * 1000, NAME_None, true);
     USceneComponent::TickComponent(deltaTime, TickType, ThisTickFunction);

And I added this to the constructor:

 PrimaryComponentTick.bCanEverTick = true;
 PrimaryComponentTick.EndTickGroup = ETickingGroup::TG_PrePhysics;
 PrimaryComponentTick.Target = this;

have i done somethign wrong? And how can I fix that?

Product Version: UE 4.21
more ▼

asked Dec 30 '18 at 11:42 PM in C++ Programming

avatar image

10 1 4 8

(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