- Home /
Unity3D Pressure Plate request.
Hello,how can i make pressure plate in unity3d,I want to make it work like when you step on it some action starts to going,like doors opening,elevator starts going and so on... Something like in Minecraft.Well i also need:I want it to sink when an object such as a box is put on it. When the object is removed I want the plate to pop back up to its original position.
I know this is going to be extremely hard.Please help i dont have any idea how to do this.
just out of curiosity - and this is no personal reflection or criticism (I too am impressed with the above graphic =] ) - but how much program$$anonymous$$g experience do you have? and what languages / programs? When I started Unity (just this year!) I did alot of tutorials until I learned how to get things to work as I imagined. $$anonymous$$achines are stupid so it's up to you to tell it what to do, and code is like lego : all the pieces are a standard item but how a person puts those bricks together ....
So to tackle this problem : have a look at Beginner B13 – Trigger Collision Detection on this link : http://www.unity3dstudent.com/category/modules/beginner/
When you do that, you'll have a way of detecting if something is in a certain area. Great, now you can do that, you can think about how to use that to play an animation or run a function to lower the pressure plate slowly , then anything !
I understand learning is hard, like when I didn't know a type of command even existed, and/or was doing something the long way round. Check out all the tutorials on that link, they are like 5 $$anonymous$$s each =]
If you show code that you have written when you ask a question, you'll find that people will explain more rather than telling you not to ask for code. When people read what you write, they see your level and understanding of what you're trying to do. So have a go, keep typing - deleting - typing, and then ask on this again with your code so all can see your approach. Have Fun =]
oh, and always search this site ! even search the title of what you are about to ask first. you never know ....
The plural of sinked is sinkeds.
The past-tense active of sink is sank - "The button sank."
The other past-tense of sink is sunk - "The button is completely sunk."
The other other past-tense of sink is sunken - "The button is sunken in."
English is a silly language. :D
Answer by HolBol · Jun 25, 2012 at 10:17 AM
This is not going to be hard if you look at the documentation. Unity comes with a very deep and thorough manual that has everything you need in it.
You'll need some eye trickery- a mesh that is you stand-on button, animated to move down. Then have a trigger collider placed over it, and get the animation to play when the character enters the trigger, andat the same time have the same script call any event you like. Nobody will give you scripts. You have to work for what you want.
@Dreatix: No, this site isn't for getting programmers for free. It should be a knowledge database for Unity.
If you need a personal programmer that code your stuff for you, you might want to visit the collaboration forum
Dreatix, did you read my answer? I said "Nobody will give you scripts. You have to work for what you want". Unity comes with a documentation. I spent hours trawling through it just to get to where I am today, and I'm still pretty novice and have been since I stated with Unity about 24 months ago. If you want to make games, you have to put time and effort into it.
Answer by luniac · Dec 09, 2012 at 05:48 AM
Unlike these hardasses ill at least give you suggestions where to start....
look up OnCollisionEnter()
You can apply that to the box which basically means that you can detect when you're on top of it. When that happens you can use an "animation" to make the box move down.
look up OnCollisionExit()
You can use that to detect when you leave the box and then the box will play another "animation" where it moves to the original position.
Simple animations such as the one youre trying to create can be made in engine using the animation window, so look that up and how its used.
You may want to look up tags, cause they make it easier for the box to know what stepped on it, if for example you only want the "player" to activate it.
and dam people you can at least give the man some pseudo code... god....
I believe I did provide this information in my first comment, the OP never replied or expanded on the points I raised. The OP also was posting a few questions at the time without displaying any real working knowledge (this is reflected in the karma rating also). You will come to recognize these trends after using this 'site for a while, where people just ask for code or post lots of questions at once and beyond their skill level but don't take the time to read and do tutorials.
But fair enough, this is a knowledge base, and maybe your answer will help future readers.
No Worries =]
At least you care and help, keep up the good work !
Answer by Bananaman · Dec 09, 2012 at 09:34 AM
I guess I'll be the nice guy. But before you just copy and paste into a new script. Try to understand what is happening throughout the script and why. Yes, the checking if the door is open or closed might be redundant, but it never hurts haha.
var soundclipOpen : AudioClip;
var soundclipClose : AudioClip;
var Open : boolean = false;
Function Start()
{
Open = false;
}
function OnTriggerEnter(other : Collider)
{
if (Open == false)
{
animation.Play("down animation");
animation.Play("door open");
audio.Play(soundclipOpen);
Open == true;
}
}
function OnTriggerExit(other : Collider)
{
if (Open == true)
{
animation.Play("up animation");
animation.Play("door close");
audio.Play(soundclipClose);
Open == false;
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to tell if 2 blocks are next to each other in a 2d game? 1 Answer
Cant change GO material with multipli material 1 Answer
create a GuiSkin 2 Answers
Spawning objects help 2 Answers