- Home /
Phisics question! How can I launch this object?!??!?!?!!
XXXXXXXX SOLUTION FOUND, WAS JUST TO ZERO THE VECTORS XXXXXXXXX
I have an almost done script here, it works almost fine but when I launch the model its behave isnt what I expect.
works this way: the object has this script attached and my character, when collide with its child collider is able to pick it up, it does work well, and then, he is up to launch it but the physics isnt work the way I want.
here it is:
I was reading about possible solutions for this issue, one of then is probably "Force.Impulse" other is "vector3.normalize".
since 22 days ago I knew about nothing about programming, I really dont know how to appy it, can anybody help with this??!??!?
thanks alot in advance!
var playerHand : Transform;
var pegou = false;
var soltou = false;
var upforce = 6000.0;
var frontforce = 3000.0;
function OnTriggerStay (other : Collider) {
if(other.transform.tag == "Player" && Input.GetButton("Fire1")){
pegou = true;
timeDelay = 0;
}
}
function Update() {
if (pegou){
var colisorzao = transform.parent;
colisorzao.parent = playerHand;
colisorzao.rigidbody.isKinematic = true;
colisorzao.rigidbody.detectCollisions = false;
colisorzao.position = playerHand.position;
colisorzao.rotation = playerHand.rotation;
}
if (pegou && Input.GetButton("Fire2")){
pegou = false;
timeDelay = 0.0;
soltou = true;
}
if(soltou){
colisorzao = transform.parent;
colisorzao.rigidbody.isKinematic = false;
colisorzao.rigidbody.detectCollisions = true;
transform.parent.rigidbody.AddRelativeForce (0, upforce , frontforce);
colisorzao.parent = null;
}
}
function segurar () {
return pegou;
}
function soltar (){
return soltou;
}
btw
"collisorzao" means Big Collider, "Pegou" means "held" Segurar means "hold" , "soltar" means "release"
Because this question has been answered (by yourself), please post an answer with your solution, and mark the answer as accepted. This will show that this question does no longer need a solution, and will allow for more questions to be answered. Thank You!
Also, program$$anonymous$$g is in english, always in english, one of the first things I learned in my program$$anonymous$$g class was to always use english terms because it's not made for any other language...
Your answer
Follow this Question
Related Questions
pretty weird issue with rotating a sphere 2 Answers
A node in a childnode? 1 Answer
Very simple picking up items script? 2 Answers
How would I make an object disappear after a set amount of time? 3 Answers
Errors with gravity switching... 1 Answer