WIP AGV FAQ
Changing the velocity of a motion tensor
Setting the velocity can be achieved by using the ForceVelocity
method on the motiontensor.
List<MotionTensor> motionTensors = actor.getActivitiesByType<MotionTensor>();
foreach (MotionTensor tensor in motionTensors)
{
tensor.ForceVelocity(velocity, SimulationController, _intersectionEvent.EventTime);
}
Stopping a motion
Setting the velocity of a motiontensor to zero will stop the movement.
List<MotionTensor> motionTensors = actor.getActivitiesByType<MotionTensor>();
foreach (MotionTensor tensor in motionTensors)
{
tensor.ForceVelocity(0, SimulationController, _intersectionEvent.EventTime);
}
Reversing a motion
DES supports a negative velocity, to move it in reverse simply use a negative velocity.
List<MotionTensor> motionTensors = actor.getActivitiesByType<MotionTensor>();
foreach (MotionTensor tensor in motionTensors)
{
tensor.ForceVelocity(-velocity, SimulationController, _intersectionEvent.EventTime);
}
Getting the current velocity of a motion tensor
The velocity of the motiontensor can be retrieved from the tensorcomponents with the following code.
Parent an actor to another actor
To parent an actor the following code can be used.
Unparent an actor
To unparent an actor the same code as for parenting an actor can be used. The only difference is that instead of the child it passes null to unparent.
Starting a timer
A timer can be created and started with the following code.
Destroying an old motion
Destroying an old motion tensor can be achieved with the following code.
Creating a new motion
A new motiontensor can be generated with the following code.
Executing DES code from outside the DES system
When changing things in the DES system, you have to have the frametime passed and eventtime. Therefore the actions can only be called from inside DES. If you’d like to call these functions from outside of DES, you’ll have to pass them to an instructor and execute them in the next frame with the OnSimulationFrameUpdate
.
Execute code every frame
Because the DES system can run at faster then real time, frame updates should no longer be executed with the FixedUpdate
but rather with the override of the OnSimulationFrameUpdate
in the DESInstructor
.
Change splines
To change splines, the old motiontensor should be destroyed and a new motiontensor with the new motiontensor should be created.
Generate a motion tensor from code and set the position on the spline from the world position
The motiontensorview has a feature that adds the actor to the closest point on spline when starting the motion. To do the same in code, you can manually calculate the percentage and then create a new motiontensor with that percentage.
Related content
Prespective Documentation