Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  actor‘s update time
#6
(29-12-2020, 09:36 AM)josemendez Wrote: Particle positions are updated immediately. See above.

I don’t quite understand your use case. Could you post the code you’re using?

Thank for you response.

Of course, no problem,there is my part code.

I use this code to get particles position,those particles can simulate "control point" position.
I have two ropes so i put them in a List.
index and position is global.

Code:
void get_index()
{
    for(int i = 0; i < numofballs.GetLength(0); i++)
    {
        for(int j = 0; j < numofballs[i]; j++)
        {
            index[i][j] = actor[i].solverIndices[rope[i].blueprint.groups[j].particleIndices[0]];
        }
    }
}
    

void get_position_now()   
{
    for(int i = 0; i < numofballs.GetLength(0); i++)
    {
        for(int j = 0; j < numofballs[i]; j++)
            {
            position_now[i][j,0] = actor[i].GetParticlePosition(index[i][j]).x;
            position_now[i][j,1] = actor[i].GetParticlePosition(index[i][j]).y;
            position_now[i][j,2] = actor[i].GetParticlePosition(index[i][j]).z;
        }
    }
}

And this is my move code.
action is a int variable come from other file.
I use ObiParticleAttachment to connect target paricle to rope position,so i can move target particle position when i move rope position.
controlling_ball is a array variable i use to save target particle umber.

Code:
before_position = get_position_now();


int action = Convert.ToInt32(strArray[1]);
if(action == 0)
{
        Vector3 to_new_position = new Vector3(0.0f, 0.0f, -position[controlling_ball[0]][controlling_ball[1],3]);
        rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);   
}
if(action == 1)
{
        Vector3 to_new_position = new Vector3(0.0f, 0.0f, position[controlling_ball[0]][controlling_ball[1],3]);
        rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 2)
{
        Vector3 to_new_position = new Vector3(-position[controlling_ball[0]][controlling_ball[1],3], 0.0f, 0.0f);
        rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 3)
{
        Vector3 to_new_position = new Vector3(position[controlling_ball[0]][controlling_ball[1],3], 0.0f, 0.0f);
        rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 4)
{
        if(rope[controlling_ball[0]].gameObject.transform.position.y > position[controlling_ball[0]][controlling_ball[1],3])
        {
                Vector3 to_new_position = new Vector3(0.0f, -position[controlling_ball[0]][controlling_ball[1],3], 0.0f);
                rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
        }
}
if(action == 5)
{
        Vector3 to_new_position = new Vector3(0.0f, position[controlling_ball[0]][controlling_ball[1],3], 0.0f);
        rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}




after_position = get_position_now()


You see, i want before_position and after_position, is this possible?
Wait for your answer
Reply


Messages In This Thread
actor‘s update time - by FZMv587 - 28-12-2020, 09:45 AM
RE: actor‘s update time - by josemendez - 28-12-2020, 03:48 PM
RE: actor‘s update time - by FZMv587 - 28-12-2020, 03:52 PM
RE: actor‘s update time - by FZMv587 - 29-12-2020, 08:28 AM
RE: actor‘s update time - by josemendez - 29-12-2020, 09:36 AM
RE: actor‘s update time - by FZMv587 - 29-12-2020, 10:13 AM