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"

Changing Length of Laser Beam on Collision?

Hello there! I'm trying to improve the concept explained in this tutorial. The difference between the tutorial's laser beam and my idea is that my lasers' lengths would change when they come into contact with a physics object. This would allow objects to be used to block out the beam. When the tutorial lasers spawn, their length is set. If anything gets in their way, or what was once in their way is moved, their length remains the same.

I added thisThis to the tutorial blueprint so that when a piece of furniture overlaps with the box, it does another line trace, and the location the trace hits (in this case, the table) becomes the new beam end point. Instead, the beam created goes in a completely different direction, as shown: What Happens I ran an experiment to see if the line trace hit other objects when the table entered the box (shown as the wireframe), and the line trace hit any object except the table which triggers the trace itself. When the trace actually does hit something, the laser length changes as expected. The table is an actor blueprint, which may have something to do with it. How can I make the line trace notice my table?

Product Version: UE 4.16
Tags:
thing-i-added.png (135.1 kB)
what-happens.png (600.0 kB)
more ▼

asked Aug 19 '17 at 11:58 PM in Blueprint Scripting

avatar image

w. o b.
6 1 2 3

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

3 answers: sort voted first

Hi there. There's a couple of things I would try:

  1. If you're already using a line trace to get the original endpoint of the beam, I would attach a branch node to the return value of the trace that will return true if there is a hit. From there you can set the Beam end point to the Impact Point vector from the hit result. The impact point will return the exact vector that the trace hits, rather than the location of the hit actor (I could be mistaken but I believe that the Location pin returns this.) If Blocking Hit returns false, you can set the end point to the original location. This would eliminate the need for the overlapping box and allow you to place any object with collision in the lasers path to block it. If you want the end point to change only when it hits a specific object like the table, you cast to it from the hit actor pin. alt text

  2. With your current setup, the only thing I guess is going wrong is maybe that the table mesh is not at a relative position of zero. Is it offset from its root component? Try setting from the impact point and see if that makes a difference.

Anyway, hope this helps!

more ▼

answered Aug 20 '17 at 01:25 AM

avatar image

Drkephrim
31 2 5

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

That helped a whole lot. The laser's length is affected by props now. Thanks for the quick reply! I tested your idea out, and I think the line trace will work to solve the problem. If you have a little more time to help, the solution raises a few more problems. Here's the real troubling one:

As I said, the laser's length is affected by props. alt text When I move the television away from the beam, its length does increase. alt text I haven't done the programming for the wireframe box yet, but don't worry about it. As you said, I might not need it. The problem now is that whatever length the laser is when it is spawned is the laser's minimum distance. Does your laser do this? If so, how would you set the laser so that its minimum length is 0? alt text

more ▼

answered Aug 20 '17 at 07:03 PM

avatar image

w. o b.
6 1 2 3

avatar image Drkephrim Aug 20 '17 at 08:24 PM

Happy to help. I'm not sure what's going on there, because it's almost as if its ignoring the collision of the television if its overlapping the box. Not sure what it possibly be doing if it;s working outside of those bounds. I threw something together just now to see if I could replicate it, but it seems to be working fine. If you using a cascade particle system like I am, this set up should get you what you're looking for. (Unless it's only working on my end :P)alt text

Again, I'm not sure what your set up looks like, but for me it produces this result: alt text alt text

As you can see, I'm able to move the prop very close and across the room, and I've tested position in between successfully. This works with both static mesh actors and blueprint actors, so long as they have a mesh with collision. I hope this get you in the right direction!

Cheers!

avatar image w. o b. Aug 20 '17 at 10:30 PM

Congratulations, you saved my entire game!alt textalt text Can't thank you enough. One quick question- could I see your laser's particle system? It's less blindingly bright than mine, which is good. You've done good. Thank you again.

before.png (678.1 kB)
after.png (714.5 kB)
avatar image Drkephrim Aug 20 '17 at 10:44 PM

Sure thing. It's just a simple gradient I threw together in photoshop. I'll have to see if I have the original texture anywhere, as I've been just migrating from old projects. I'll link the .uassets here, you should be able to unzip it into your content folder. If there are any issues, I can send you the entire project I made earlier, so you can migrate manually.

avatar image viniciusc1994 Jan 12 '18 at 09:35 PM

Hey Drkephrim, Would you mind sending me the project having a hard time putting this together with a motion controller. Would help out a lot! Thanks.

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

I am trying to use this function on my motion controller and my laser just goes through collision no matter what, and its always the same size. I am updating my beam source point on event tick since the controller is always moving. Any ideas? Completely lost at this point I have tried what I know. alt text

debug.png (274.9 kB)
more ▼

answered Jan 12 '18 at 08:21 PM

avatar image

viniciusc1994
1 1 2

(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