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"

Check which direction the player was hit from?

This has proven to be a real head scratcher since I am so close, but Unreal's strange -180 to 180 degree rotation system is really throwing a wrench in the works.

I have made a wall running mechanic, but I want to figure out which way to lean the camera while wall running. (For game feel)

Literally all I need to do is use the information from my "Hit" event node to figure out which side of the player the wall is one (Left or Right).

It really is that simple, but I am having so much trouble with this. I thought the obvious answer would be to take the Normal rotation of the wall surface, and then subtract the player rotation, and boom. I would have a Rotator that I can use to pinpoint exactly on which side the player was hit. But the rotation system really gets in the way of this.

Does anyone have any other methods? (Cheers)!

Product Version: UE 4.19
Tags:
more ▼

asked Nov 20 '18 at 12:51 PM in Blueprint Scripting

avatar image

Raxs_Slayer
171 8 18 20

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

1 answer: sort voted first

Don't try subtracting rotations, that won't do you any good.

What I came up with from the top of my head is this:alt text
In this case when the Character is hit from the left, the value will be positive, is from the right — negative, both within (0,180).
Hope that helps.

hit.png (125.7 kB)
more ▼

answered Nov 20 '18 at 04:22 PM

avatar image

Tuerer
1.8k 12 7 9

avatar image Raxs_Slayer Nov 20 '18 at 04:25 PM

Hi Tuerer, Thanks for the response.

Could you give me a quick explanation on what some of these nodes are doing? Just for my own benefit and understanding my code will help me on this project down the line.

Namely the "dot" and "ASINd" nodes.

avatar image Tuerer Nov 20 '18 at 05:29 PM

These are just common mathematical functions, I don't think I can explain it better than the Wikipedia can.
https://en.wikipedia.org/wiki/Dot_product
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions

Edtd: Basically these two nodes together return the angle between two vectors.

avatar image Raxs_Slayer Nov 23 '18 at 12:32 AM

Okay, I finally got my head around the nodes. I didn't find the Wikipedia pages as much help since they are extremely comprehensive.

But for anyone else: from what I gathered, the Dot, node compares the similarities between two vectors on a range from -1 to 1. Specifically as normal directions.

Then the ASINd converts them to degrees. But, for my case anyway, Dot was all I required to get the results I needed.

avatar image Arty-McLabin 3 days ago

it should be ACOSd, not ASINd.

(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