Results 1 to 4 of 4

Thread: How to make an object change to a different object when clicked on?

  1. #1

    Question How to make an object change to a different object when clicked on?

    I want to know what script I would use to make an object change into a different specific object when clicked on. I'd like the new object to be able to be changed back to the original object when clicked on as well. In this instance, I'm wanting a closed door object to change into an open door object, and vice versa, when clicked on. Any advice/help would be much appreciated.

    Thanks

  2. #2
    The easiest way to do this is to use STATES, which is a function that dose not require any scripting.

    Just place both objects next to each other, drag a box around them, right click on one and go "create states"... it now becomes one objects. If you have 3 objects, hovering over the object with your mouse and pressing 1,2 or 3 will change the object to that one. These are "true" objects though, they can be of any type, have new textures, have different scripts of flags for snaps or w/e. each uses the same 0,0,0 mark so if you are good at modelling and using pivot points you can actually have the object move when you change state (I made a clock face once that pressing the state made the clock go forward in time, as a round timer.)'

    The other method would be is use customObject and reload().. basically you can build a object in scripting then apply it as parameters then reload the object and it will have the new attributes like mesh or colours or w/e... but it will have the same scripts and any attributes you did not actually change.

    Another option is to use infinite bags, i've used this before. So on click you draw a open door from a infinite bag, get the door you clicked on data for position and rotation and scale and stuff, then move the new object to that spot instantly and delete the old one at the same time, same to switch back.

  3. #3
    You can also have the script spawn a new object and then destroy itself.

    The State solution above will work if you know, ahead of time, what the object will change into and, as stated, it is probably one of the easiest way to implement what you have described. You can also change the state through scripting (so you could still have a script for the pickup object event and enforce the state change).

    The customObject solution and the spawn/destroy options both would require a little more scripting to achieve.

  4. #4
    You guys are LEGENDS! Thank you!

Similar Threads

  1. How to make an object translucent?
    By Pheo in forum General Discussion
    Replies: 1
    Last Post: 04-15-2018, 07:06 AM
  2. Replies: 1
    Last Post: 09-20-2017, 08:30 PM
  3. Replies: 5
    Last Post: 09-06-2016, 07:02 AM
  4. Change custom object
    By Skorpion9x in forum Scripting
    Replies: 2
    Last Post: 05-12-2016, 07:08 AM
  5. Replies: 2
    Last Post: 09-18-2015, 05:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •