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"

How CurrentForwardSpeed Works?

I think this will be a simple question for most of you. I'm looking at the C++ Flying template, and inside of the pawn code I see code like this:

 CurrentForwardSpeed = FMath::Clamp(NewForwardSpeed, MinSpeed, MaxSpeed);

I think I'm missing the basics of how the code is structured. Is CurrentForwardSpeed a built in variable of the Actor class that's being overwritten? is that how the engine knows what the new Forward speed is?

The reason I'm asking is because I'm just trying to do simple manipulations such as, add vertical and horizontal thrusts.

Product Version: Not Selected
Tags:
more ▼

asked Mar 07 '15 at 09:46 PM in C++ Programming

avatar image

Snipe3000
74 20 21 24

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

1 answer: sort voted first

CurrentForwardSpeed is not built in, but rather defined by the particular subclass of APawn you're viewing currently. Every Tick, it is used to calculate an FVector identified as LocalMove that is passed to AddActorLocalOffset (which is a built-in method of AActor). That will then cause the engine to move the pawn at its current speed.

The FMath::Clamp function you referenced is used to set upper and lower bounds on the current speed, i.e. so the pawn can't move any faster or slower than MaxSpeed and MinSpeed respectively.

more ▼

answered Dec 20 '16 at 10:41 PM

avatar image

Leirith
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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