Right approach to change materials of actors by widget

And no, Left grip didn’t print a
string while try to select the FALK-TR
actor.

That was not what I asked. Let me rephrase:

  • Print String immediately after Grip before the branch. Does it print? If it does not, none of the above matters as you need it working first. Did it work before? Have you ever successfully done anything with that Grip trigger?

There are many ways to line trace but none of them will work if the controller is not evoking input.

What is that controller anyway, Oculus?


One way or another, you can script the logic with the mouse in mind for the time being, get the interaction working, and then replace the relevant bits with functionality that’s unique to the controller you’re using.

I have 8 FALK-TR actor BP in my level,
numbered from FALK-TR1 to FALK-TR8

How is the BP class called in the Content Browser, where you drag the actor from to place them in the scene? The equivalent of aMyActor in the very first image I posted.


You say:

I have 8 FALK-TR actor BP in my level

But you cast to FALK-TR1 - so that’d be a different class already that’d always fail the cast. Could you please clarify how many classes are we working with here? If those 8 instance that you have in the LB are to share similar functionality, they should be of (or inherit from) the same class.

To clarify, you can name the actors in the LB however you want - these are just user friendly names.

Is the Get Hit result under cursor by channel in the LB correct?
In your project you are using a mouse, I am using a motion controller…

First I have set up 1 cube right now for testing purposes.
Set the SelectedActor var to that cube actor and set up the rest like the others earlier. If I got the cube working, I guess the rest will follow.

The leftGrip is working, it post a print string before the branch.
Is was always working, because I had set the visibility of the widget to Left Grip.
For testing I have set the widget to always visible right now.

See attachm. for the level BP’s of the FALK actors. I think there is also something not correct in the BP classes?

I use the Vive controllers.

These are not classes. These are instanced actors. Classes sit in the Content Browser:

340668-screenshot-4.png

These are the classes. How many FALKs are here?

Could you clarify one thing for me? Why is this done in the LB? Why not the Pawn / Controller where you have the Motion Controller component (do you)? My original suggestion was in the Pawn. Not sure when this whole thing was shifted to the LB…

Right approach to change materials of
actors by widget

Normally, in VR, you’d have Widget Interaction Component translating device input. And then have it interact with whatever fancy VR devices you’ve got. How familiar are you with this?

It’s pretty much the same as interacting with 3d menus from the first person perspective view point. You wouldn’t use the get hit under cursor because you have no cursor - you’re holding a gun / magic staff or whatnot and point with it in a direction.

My original suggestion was a mere method you’d need to apply to the VR equipment you’re using. Also, if the colour picker serves just this one purpose, I’d make it the part of the player, too. No need to complicate things further.


Anyway, the whole objective here is to point with a device, trace, hit the object, store the reference if it’s the right class or discard it if it’s not. The widget your interact with via Widget Interaction Component has dispatch the data to whoever is listing.

You already have a beam and all, right. Use that for getting the Hit Actors instead, since mouse is, of course, pointless here.

I can’t post images of how to set this up as I simply don’t own a Vive set. I only responded to the post as I believed it’s about passing data between entities - VR has nothing to do with that per se. VR-specific interactions are not my domain, though.

Sorry.

ok thanks for the explenations! I have a left controller with a laserbeam, that interacts with the VR world (on hover and so on). Don’t know how to set this up for Leftgrip hit Actor? I searched a lot on YT and internet, but couldn’t find the info that fits me.

BTW, I have 8 classes of FALK BP - 1 till 8. What I have done is imported meshes by Datasmith of a 3D project I made earlier and select a mesh and made it a BP (on the button BP/Add script) That;s probably not the right way in my case?

I have set up a test cube now and set the click event on Left mouse button.
It prints a string selected when clicking the cube and unselected when clicking other actors in the scene. So that works…

Still can’t get change the colours, the widget is set on always showing, and I have set 2 colours in the widget on hovering, but it doesn’t work. Maybe there is no mouse activity in the widget? I play the level in Selected Viewport mode.

I had set a SelectedActor variable in the LB and also in the TestCube BP. Set on the actor Testcube variable type. Or is that not necessary to do it also in the TestCube BP? Or is it not working correctly when having those 2 variables?

This is what I got right now…

I got it working with the testcube and mouse input!

Questions left for me are:
How can I set the different actor BP’s of my different static meshes to 1 BP class, so I can cast to it in the LB?

And how can I set the Left Trigger of the controller to select Actor in level?

The hover over colors and the close button of the widget works well.

I placed the motion controller input issue in a new post on this forum…

For the BP Class, can I select all the TR BP’s in the outliner and convert selection to BP class? Will that work when casting to that class? Or must they be multiple actors in the outliner, like in your example?

It’s up to you how you handle classes. If you do not cast to a specific class, you’ll get hits on everything - all actors.

The cast here serves only as a filter so we do not accidently grab something undesired. There are many ways to filter what you need - taking advantage of the cast failing seemed the most straightforward here.

You select an object, check if it’s of a specific class via a cast. If it succeeds - the object is of the desired type, and vice versa.

Thanks for the reply.

I made some changes in the setup, see attachments and the widget appears when selected the right actors of a class, that works well.

Only thing I can’t get working is the material change, it changed the staticmesh0 only and not the others when selected. I have placed all the actors in one BP class and set the material slots right.

What have I done wrong or has just to be done?
Thanks in advance!!

I don’t follow this. If this is the actor then why does it have a Selected Actor variable? Why does it refence itself? The only thing the actor needs in the construction script is in the very first image I posted.

  • this actor crates a dynamic material for one of its static meshes:


  • in some other blueprint, where you grab things you will pick an actor from the scene
  • by using the reference, you gain access to its dynamic material and set values there:

I set this all up… When I print the actor name in a string and select the different actors in the level, I only get the name of the BP these actors are in. So it doesn’t know which actor is selected I pressume? My project differs from your, while you got a BP class and seperate actors in the level…?

And if I understand correctly your above post, the construction script has to be set only for one static mesh?

I am really sorry. But I truly no longer understand what you’re trying to do.

In my head:

  • you have some actors hanging about in the level
  • each actor has a bunch of static meshes
  • each actor has 1 dynamic material assigned to one or more static meshes
  • you use a controller to select one of those actors, a widget pops-up
  • by clicking a widget button we change something in the that actor’s material

How close am I? Everything I’ve posted revolves around the above.


And if I understand correctly your
above post, the construction script
has to be set only for one static
mesh?

How am I supposed to know how many meshes you want the material assigned to? It’s your project, the examples assumes one.

If you want to change the colour of 1 mesh, assign the material to 1 static mesh. If you want to change the colour of all static meshes, assign it to all static meshes. Or to some of them.

If you wanted all the meshes to be affected by changes made in this actor’s dynamic material.

I feel like I’ve posted an answer but it got moderated? Did I misspell ‘but’ again?

Thanks for the reply and patience!

That can I also use in another part of my learning project!
What I did till now:

  • I had imported a 3D model from 3D software with Datasmith to unreal.
  • These came in as 8 seperate meshes (with 3 materials per mesh)
  • While trying some things to fix, I made BP’s of each of it.
  • Later on I setup the nodes like you said above in this post.
  • Yesterday I converted all the 8 Bp’s (with the 1 mesh in it per BP) to a BP class.
  • Now I have a BP Class with the 8 static meshes in it.
  • The material change works fine (but for 1 mesh in the BP class) and the widget works also fine (colour change on hover)

The confusing for me starts with the BP class. To cast to a BP I needed the class, like in your example.
I have now just one actor in my scene (the BP class with the static meshes in it)
Thats why I am totally lost right now…

The material change works fine (but
for 1 mesh in the BP class) and the
widget works also fine (colour change
on hover)

So what is not working? Do you want to apply a different colour to each of the static meshes separately?