Posts: 2
Threads: 1
Joined: Aug 2019
Reputation:
0
16-09-2019, 01:47 AM
(This post was last modified: 16-09-2019, 11:01 AM by harapeco.)
Hello.
I'd like to move softbody object with script.
for example, attach above code to softbody object.
Code: using UnityEngine;
using System.Collections;
public class Gravity : MonoBehaviour {
public GameObject planet;
public float accelerationScale;
void FixedUpdate () {
var direction = planet.transform.position - transform.position;
direction.Normalize();
GetComponent<Rigidbody>().AddForce(accelerationScale * direction, ForceMode.Acceleration);
}
}
Is it able to do this?
or if not, how can i do like this.
Posts: 27
Threads: 6
Joined: Jul 2019
Reputation:
1
23-09-2019, 12:44 AM
(This post was last modified: 23-09-2019, 12:48 AM by tegleg.)
like this
Code: GetComponent<ObiActor>().AddForce(accelerationScale * direction, ForceMode.Acceleration);
have a look at AddRandomVelocity.cs used in the ball pool demo
Posts: 35
Threads: 14
Joined: Nov 2019
Reputation:
0
12-11-2019, 04:11 PM
(This post was last modified: 12-11-2019, 04:11 PM by manurocker95.)
(23-09-2019, 12:44 AM)tegleg Wrote: like this
Code: GetComponent<ObiActor>().AddForce(accelerationScale * direction, ForceMode.Acceleration);
have a look at AddRandomVelocity.cs used in the ball pool demo
and how do I set an obi actor by transform position?
Posts: 6,329
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
12-11-2019, 04:42 PM
(This post was last modified: 12-11-2019, 04:46 PM by josemendez.)
(12-11-2019, 04:11 PM)manurocker95 Wrote: and how do I set an obi actor by transform position?
Hi,
Mathematically speaking it is impossible to define the orientation/position/scale of any deformable object using a single transform. Where's the "center" of a t-shirt? how much is it rotated/scaled when worn? and when folded in a drawer? or crumpled in the laundry basket?
So you have to be much more specific about what you mean by "set by transform position".
- You could fix some particles in your actor, and then set the position of those (ObiHandles).
- You could perform the simulation in local space, then move the reference frame of the simulation around. See: http://obi.virtualmethodstudio.com/tutor...space.html
Posts: 35
Threads: 14
Joined: Nov 2019
Reputation:
0
(12-11-2019, 04:42 PM)josemendez Wrote: Hi,
Mathematically speaking it is impossible to define the orientation/position/scale of any deformable object using a single transform. Where's the "center" of a t-shirt? how much is it rotated/scaled when worn? and when folded in a drawer? or crumpled in the laundry basket?
So you have to be much more specific about what you mean by "set by transform position".
- You could fix some particles in your actor, and then set the position of those (ObiHandles).
- You could perform the simulation in local space, then move the reference frame of the simulation around. See: http://obi.virtualmethodstudio.com/tutor...space.html
I already made another thread, but now I have a grasper that must be able to grab an object and pull it while it deforms. Now, for doing things simple, it follows the grasper transform while moving it, so I need the entire object to follow that transform. Actually, the example grabber is what I need but without that bouncing effect.
Posts: 6,329
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
13-11-2019, 02:42 PM
(This post was last modified: 13-11-2019, 02:43 PM by josemendez.)
(13-11-2019, 01:25 PM)manurocker95 Wrote: I already made another thread, but now I have a grasper that must be able to grab an object and pull it while it deforms. Now, for doing things simple, it follows the grasper transform while moving it, so I need the entire object to follow that transform. Actually, the example grabber is what I need but without that bouncing effect.
Why not slightly modifying the included grabber then? Instead of adding a force to each particle (solver.externalForces, which is what the grabber does) set their position directly (set solver.positions instead). If you want the grabbed particles to have no dynamics while grabbed, also set their inverse mass and their velocity to zero.
Posts: 35
Threads: 14
Joined: Nov 2019
Reputation:
0
(13-11-2019, 02:42 PM)josemendez Wrote: Why not slightly modifying the included grabber then? Instead of adding a force to each particle (solver.externalForces, which is what the grabber does) set their position directly (set solver.positions instead). If you want the grabbed particles to have no dynamics while grabbed, also set their inverse mass and their velocity to zero. The thing is that:
1) I need to know what particles are being touched by the grasper and any of the current callbacks allow to know that
2) Even if I set the position of the dragged particles, I need the rest of the particles to follow the position but applying dynamic physics, so could you make an example to know how would it be done?
Posts: 6,329
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-11-2019, 10:18 AM
(This post was last modified: 14-11-2019, 10:18 AM by josemendez.)
(14-11-2019, 09:54 AM)manurocker95 Wrote: The thing is that:
1) I need to know what particles are being touched by the grasper and any of the current callbacks allow to know that
2) Even if I set the position of the dragged particles, I need the rest of the particles to follow the position but applying dynamic physics, so could you make an example to know how would it be done?
1) You can use collision callbacks to get the particles touching the grasper:
http://obi.virtualmethodstudio.com/tutor...sions.html
2) When you set the position of some particles, all other particles follow them automatically because they are interlinked via shape matching constraints. There's nothing you need to do for this to happen. Simply move the particles you need, the rest will follow.
Posts: 35
Threads: 14
Joined: Nov 2019
Reputation:
0
(14-11-2019, 10:18 AM)josemendez Wrote: 1) You can use collision callbacks to get the particles touching the grasper:
http://obi.virtualmethodstudio.com/tutor...sions.html
2) When you set the position of some particles, all other particles follow them automatically because they are interlinked via shape matching constraints. There's nothing you need to do for this to happen. Simply move the particles you need, the rest will follow.
About 1) gonna try that, but more examples should be added to the package to cover these kind of things.
2) Not really: https://gofile.io/?c=mbKTnQ
the script just set the positions as:
solver.positions[pickArgs.particleIndex] = (targetPosition);
Posts: 6,329
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-11-2019, 10:39 AM
(This post was last modified: 14-11-2019, 10:41 AM by josemendez.)
(14-11-2019, 10:24 AM)manurocker95 Wrote: About 1) gonna try that, but more examples should be added to the package to cover these kind of things.
2) Not really: https://gofile.io/?c=mbKTnQ
the script just set the positions as:
solver.positions[pickArgs.particleIndex] = (targetPosition);
Hi Manu,
The video you sent causes VLC, Quicktime and Media Player to crash, so I'm unable to see it.
When setting positions directly you also need to set the inverse mass and the velocity of these particles to zero, as I pointed out before. Setting the inverse mass to zero deactivates dynamics for that particle (as you will be setting its position directly, and you don't want the simulation to overwrite it), and removing all its velocity will make sure it doesn't drift away from the position you set.
Once you "release" the particle, simply set its inverse mass to whatever it was. The simulation will take over and begin setting both its position and velocity.
From the manual:
http://obi.virtualmethodstudio.com/tutor...icles.html
Quote:Inverse mass for each particle. An inverse mass of 0 means the particle's mass is infinite, so its position will be unaffected by dynamics (allowing you to override it manually).
|