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"

Change actor location randomly within box

I am trying to make a coin (just a black cylinder) disappear, change to a new random location within a specific area, and reappear every time I press the right mouse button. My level blueprint successfully makes the coin disappear, change location, and reappear when I click the right mouse key, but it often appears at locations outside of my quadrant 1 box that I want it to stay within. Does anyone know what I might have done wrong in my code to allow the coin to appear anywhere outside of the box that I want it to stay within?alt text

Product Version: UE 4.20
Tags:
levelimage.png (976.8 kB)
randomfloatbp.png (340.7 kB)
more ▼

asked Nov 26 '18 at 05:29 PM in Blueprint Scripting

avatar image

sisker321
3 1 2

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

2 answers: sort voted first

The error is probably that you add random location to already existing Coin location instead of just setting the random location itself to it. You may want to use this out-of-the-box (pun intended) method to reduce the possibility of errors in your code:

https://api.unrealengine.com/INT/BlueprintAPI/Math/Random/RandomPointinBoundingBox/index.html

more ▼

answered Nov 27 '18 at 08:04 AM

avatar image

Hustlan
310 3 4 10

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

I accidentally posted this question twice. Here is the other post with an answer that solved my problem. Basically, the issue was that I attached the coin reference to the node that determined the new location, so I was adding the random coordinates to the most recent location of the coin instead of to the center of the quadrant. I unsplit the origin of the Quadrant1 actor and plugged that into the node that adds the new random x and y coordinates. Here's a link to that other post.

https://answers.unrealengine.com/questions/852092/view.html

more ▼

answered Dec 05 '18 at 06:45 PM

avatar image

sisker321
3 1 2

(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