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"

Calculate the direction of a static mesh?

I've been trying to figure this one out for a little while now and I am really struggling. Within the context of a rolling ball controlled by torque, what would be the best way to calculate the direction that the ball is rolling in as a rotation. I've been playing around with velocity and all that but I just can't work it out!!

Any help would be greatly appreciated.

Product Version: UE 4.19
Tags:
more ▼

asked Apr 04 '18 at 04:50 PM in Blueprint Scripting

avatar image

Ben Carter
3 2 5

avatar image salm Apr 04 '18 at 04:57 PM

What effect are you trying to achieve? You've tried the 'Rolling' start template in UE. I feel like it was added recently.

avatar image Ben Carter Apr 04 '18 at 05:02 PM

The goal is to know what direction the ball was rolling toward so that I could have something in front or behind it at any time. So I would need to know the direction of a rotation so that the ball could have an artificial front and back

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

1 answer: sort voted first
  1. Create a Vector3 variable for the ball called "LastPosition"

  2. On begin play set LastPosition to the ball's current position

  3. On each tick subtract the ball's current position by the LastPosition variable

  4. This will give you a length/direction of the ball's movement

  5. Store the ball's current position in the LastPosition variable

This should provide you with the forward direction of the ball, provided that it is actually moving.

more ▼

answered Apr 04 '18 at 05:37 PM

avatar image

Velrin
375 2 10 13

avatar image Velrin Apr 04 '18 at 05:39 PM

Vector3 -> FVector

I get Unity and UE mixed up sometimes :)

avatar image Ben Carter Apr 04 '18 at 05:47 PM

Hey, Sorry to be a bother but an FVector doesn't exist in the Variable type list (Edit) Also, I don't know how I can get the rotation from two vectors... Sorry, I'm being a bit slow!

avatar image Velrin Apr 04 '18 at 05:54 PM

Blueprint stores it as something similar (Vector). Perhaps even Vector3.

The position is stored in the static mesh's transform.

avatar image Ben Carter Apr 04 '18 at 06:01 PM

You're awesome! Thank you for the solution!

(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