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 to make a projectile stay on ground level

I am implementing a Mario Kart like game. I decided to start with some of the fun traps that the original Mario Karts have. One of them is a turtle that goes in a linear direction and when it hits an opponent, the opponent is destroyed. I managed to get all this behavior done. However, I am facing an issue. My spawned actor (the projectile turtle) does not stay on the ground level. It starts going bellow or above the terrain (depending on the angle of the terrain). I would like to know if there is a way to make my projectile to always stay on ground level, and if so how to I do it.

Product Version: UE 4.21
Tags:
more ▼

asked Dec 13 '18 at 11:13 AM in Blueprint Scripting

avatar image

Hard-Brooker
1 1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

There are several ways to do that.

I think the easiest way ist to decide for a fixed height, like 50cm aboth the ground. Then you do a Linetrace straight to the ground (0,0,1) and you will receive the current distance to the ground and position and so and. You can then say you want your objects z-coordinate (setWorldPosition) to be 50 aboth the hit point (be careful with world and local coordiantes)

If you want it more complex, you need the normal from the hitPoint and ou can set the angle of your shell accordingly.

more ▼

answered Dec 13 '18 at 11:31 AM

avatar image

Speckulous
520 22 10 34

avatar image Hard-Brooker Dec 13 '18 at 11:52 AM

I tried to do it like this alt text

But the problem is, when the road is in a curving shaving (arc of circle), my actor (the turtle) goes immediately under the ground and gets destroyed (It's the same thing if it's a rising or falling slope)

avatar image Tuerer Dec 13 '18 at 01:37 PM

You're setting the actor location to be where your trace hits the road, whereas it should be a bit higher than that (unless your actor's pivot is way down).
Moreover, you can try starting the trace not from the Actor Location point, but from a bit forward from that. Maybe that will help you be a bit ahead and scan the road beforehand.
P.S. How did you add the screenshot with no link? It's impossible to see in fullsize.

(comments are locked)
10|2000 characters needed characters left
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