Hello all,
i'm learnig unity from scratch and at [this link][1] you can see waht i make with a lot of effort :)
Istructions:
1.with 20click on a tree, the tree will fall
2.with 20click on a falled tree you'll get 3 wood chunks
3.with click on objects you'll carry them
4.with "y" (keyboard) you will let them fall.
5.movement with WASD :)
now, i'm facing a REALLY strange issue:
If i grab the short wooden plank, i can move free
but if i grab the AXES ...**my charachet get stucked.**
The character can move only if i let them fall hitting y on keyboard...
Even if i grab the wooden chunks generated from trees i can move...
Anybody have a idea of what happening??
----------
## Grabbing Script (JS) ##
#pragma strict
var touched : boolean;
var presa :boolean;
var ply: GameObject;
function Start () {
}
function Update () {
touched = GameObject.Find("player/Main Camera").GetComponent(raycaster).TouchSomething ;
if (presa==true) { po(); }
if(Input.GetKeyDown("y") )
{
this.transform.position = transform.position;
//this.transform.position.y = transform.position.y;
//this.rigidbody.AddForce (10, -10, 10);
presa=false;this.transform.parent = null;}
}
function po() {
this.transform.localPosition = new Vector3(0.18f,0.08f,1.0f); // centering the sword handle
this.transform.localRotation = Quaternion.identity; //must point y local, so reset rotation
this.transform.localRotation = Quaternion.Euler(-17, 259, 36); //and rotate the sword accordingly
}
function OnMouseDown()
{
ply = GameObject.Find("player/Main Camera");
this.transform.parent = ply.transform;
if (touched == true)
{//transform.position.y=42;
//this.rigidbody.AddRelativeForce(0,500,0);
presa=true;
}}
[1]: http://gpsoftware.org/Unity/27042014/
↧