Announcement

Collapse
No announcement yet.

Clicking on objects as trigger - How to do that?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Clicking on objects as trigger - How to do that?

    Hello, guys.

    I'm building an architectural environment (you can take a look here) that the user will be able to change some materials. For now, I'm doing that with lerp function triggered by specific keyboard keys (eg: L to change living room wall materials).

    It's a temporary solution though. I'd like to implement that by pointing to the object with the aim and clicking (like shooting with no gun). But I have no idea on how to even start implementing that . Do you have any tip?
    Thanks.

    #2
    Have you seen the mouse interface gem over at the UDN? That might be helpful to you

    Comment


      #3
      Originally posted by jlhill17 View Post
      Have you seen the mouse interface gem over at the UDN? That might be helpful to you
      Yep, I had already seen that. The problem is that, if I understood correctly, this method will render a cursor on the screen. What I need is an FPS game and the interaction is going to be based in the aim on the center of the screen. It's like an invisible gun.

      Maybe the way is to create just that. An invisible gun with invisible bullets and making the walls changing the material when taking shots...

      Comment


        #4
        That's actually pretty easy, there's a Deproject node in Kismet that will take a screen coordinate and send it out and tell you what it hits. Since it's in the middle of the screen you already know the screen coordinate so you'd just set an event every time you click to send out a deproject from that point and then compare the object it hits to whatever objects you're wanting to change.

        Comment


          #5
          Originally posted by darthviper107 View Post
          That's actually pretty easy, there's a Deproject node in Kismet that will take a screen coordinate and send it out and tell you what it hits. Since it's in the middle of the screen you already know the screen coordinate so you'd just set an event every time you click to send out a deproject from that point and then compare the object it hits to whatever objects you're wanting to change.
          It sounds like a nice solution.
          But I've just tested it and I can't get it working. I'm not sure on how to use the Deproject node but I think it's like that:



          But it doesn't matter where I'm looking at when I press the button, the material always change...

          Comment


            #6
            X and Y take a float parameter that is the relative (between 0 and 1) screen position where the check should be performed. So in your case you should link a 0.5 up there if you want to check the center of the screen.

            Comment


              #7
              Originally posted by Crusha K. Rool View Post
              X and Y take a float parameter that is the relative (between 0 and 1) screen position where the check should be performed. So in your case you should link a 0.5 up there if you want to check the center of the screen.


              The material keeps changing no matter where I'm looking at in the game... Since the only whey it can happens is if the comparison A == B is true, I think the problem is still the Deproject function because it's being consider always true. But there is not a lot of parameters to change there...

              Comment


                #8
                Hello, guys. I've found the problem of that. The X and Y variables are not relative to screen... They are actually the pixel position of the screen. I set them to 960 (1920/2) and 540 (1080/2) and now it works from the center of the screen.

                Comment

                Working...
                X