hi everybody.i have a big problem and i dont know how can i have an elevator in my game.that move up and down by pressing the related button.as the reality.thanks for your answer
im not professional in unity ![]()
or do you have any assets related to this?
Mona, I see this is your first post to the forums, so: welcome!
You havenât asked a very specific question, so I canât give you a very specific answer. In general terms, I would make an elevator like so:
-
Get or make a 3D model of an elevator. If youâre on a Mac, I recommend Cheetah3D for 3D modeling. If youâre a masochist (on any platform), I recommend Blender. If you have no interest in 3D modeling, then youâll need to find an artist. (I donât think youâre likely to find something this specific in the Asset Store.)
-
Place the elevator in your scene.
-
Attach a script to it. This script should have a couple of public properties that define the start and end points, and probably some additional ones to define the speed and acceleration. Then, in its Update event, check for the appropriate keys or input buttons, and move from one point to another when called for.
A script like this isnât too hard to write from scratch, though if youâve never done any Unity scripting before, you will probably want to go through some tutorials and do some simpler things first. If the lerping between the two endpoints worries you, you could always leverage a good âtweeningâ framework, like HOTween.
If youâre new to Unity, you will probably get stuck on one or more of the above steps. When that happens, come back here, and post a very specific question, including (a) what you tried, (b) what happened, and (c) how this differs from what you wanted to happen. Then weâll have a decent chance of being able to really help.
Good luck!
- Joe
thanks dear joe.im new to unity.i have the 3d model and i know steps 1 and 2.but my big problem is in script.
cuz i want an elevator that has some buttons and when the character press a button the door opens,then the character goes into it,then with pressing one of the buttons related to one level the elevator goes to that level and⌠exactly something that is happening in realityâŚand writing the script isnt easy for me
By âbottomsâ do you mean to say âbuttonsâ? If not, then I canât make out what youâre trying to say.
Assuming you mean buttons, are these on-screen buttons, or do you mean keys on the keyboard (or on something like a gamepad)? If you mean on-screen buttons, are you drawing this in the OnGUI method, or using the new GUI system in Unity 4.6, or something else entirely?
(Details, details⌠you provide as many details as you can, and we may be able to help you out!)