- Home /
Rigidbody Problem - Scrolling elements
My problem is the combination of elements in the chain of Rigidbody that are scrolled. At the end of the chain is a trigger that is designed to transfer the last element to trigger the first, and vice versa. I even tried with elements hingeJoint and does not go. Does anyone have any idea how this can be solved? Preceded by some piece of code.
Could you please clarify what you mean by "scrolling" in the context of physics and rigidbodies. Are you using some GUI system like NGUI?
there are elements "trigger_row-3 1 2 3 4 5 6 7 8 9 10 11 12 trigger_row8" box are objects not use any gui. Are moved by AXIS.X code:
function Update()
{
if (Input.Get$$anonymous$$ouseButton(0)){
if(Input.GetAxis("$$anonymous$$ouse X")<0){
//Code for action on mouse moving left
Physics.gravity = Vector2(-5f,0);
row_3_colide.actives = true;
actives = 0;
}
if(Input.GetAxis("$$anonymous$$ouse X")>0){
Physics.gravity = Vector3(5f,0,1f);
row8_colide.actives = true;
actives = 0;
}
}
GameObject.Find(row_3_colide.names).rigidbody.is$$anonymous$$inematic = true;
//GameObject.Find(row8_colide.names).rigidbody.is$$anonymous$$inematic = true;
}
if (Physics.gravity == Vector2(2f,0))
{
//GameObject.Find(row_3_colide.names).rigidbody.is$$anonymous$$inematic = true;
GameObject.Find(row8_colide.names).rigidbody.is$$anonymous$$inematic = true;
}
}
In row8 trigger
static var names : String;
static var count : int = 0;
static var actives : boolean = false;
function OnTriggerStay(colider : Collider)
{
names = colider.name;
}
function OnTriggerExit(colider : Collider)
{
if (colider.transform.position.x > GameObject.Find("row8").transform.position.x && GameObject.Find("row-3").name != null)
{
colider.rigidbody.drag = 1;
//colider.rigidbody.hingeJoint.connectedBody = null;
this.gameObject.GetComponent(Follow_1).actives = true;
colider.transform.rigidbody.$$anonymous$$ovePosition(Vector3(-2.5f,2f,8f));
//colider.transform.position.x = GameObject.Find("row-3").transform.position.x;
}
if (actives == true)
{
count++;
}
}
function Update()
{
if (count == 4)
{
//GameObject.Find(row8_colide.names).rigidbody.is$$anonymous$$inematic = true;
actives = false;
count = 0;
}
}
In row-3 trigger
static var names : String;
static var count : int = 0;
static var actives : boolean = false;
function OnTriggerStay(colider : Collider)
{
names = colider.name;
}
function OnTriggerExit(colider : Collider)
{
if (colider.transform.position.x < GameObject.Find("row-3").transform.position.x && GameObject.Find("row8").name != null)
{
colider.rigidbody.drag = 1;
//colider.rigidbody.hingeJoint.connectedBody = null;
colider.transform.rigidbody.$$anonymous$$ovePosition(Vector3(9f,2f,8f));
//colider.transform.position.x = GameObject.Find("row8").transform.position.x;
//colider.rigidbody.hingeJoint = null;
}
if (actives == true)
{
count++;
}
}
function Update()
{
if (count == 4)
{
// GameObject.Find(row_3_colide.names).rigidbody.is$$anonymous$$inematic = true;
actives = false;
count = 0;
}
}
I just use gravity, any ideas?
If I $$anonymous$$ousebutton click and axis right then all elements moving right if left moving left. Gravity is set on X axis. I expect scrolling all elements together some with constant distance. Because it will be game which I should nextly eli$$anonymous$$ate this elements from this kind of menu
Sorry almost i forgot Follow_1 script static var hingejoint : HingeJoint; static var actives : boolean = false;
function OnCollisionEnter(colider : Collision)
{
if (actives == true)
{
Debug.Log("$$anonymous$$olide obiekt:" + gameObject.name + " kolider: "+colider.gameObject.rigidbody);
gameObject.AddComponent(HingeJoint);
var otherBody = colider.gameObject.rigidbody;
hingeJoint.breakForce = 45;
hingeJoint.breakTorque = 45;
hingeJoint.connectedBody = otherBody;
actives = false;
}
}
function Update()
{
}
This script should null-ing object in trigger, and transport to row_3 and next connect to another body