Skip to content
Browse files

fix(Interactions): ensure directional drive works in local space

The DirectionalTransformDrive would not work if it was nested to
another interactable object and the MoveToTargetValue was true
because the TransformPropertyApplier would always work in world space
which meant the drive was never calculating the correct position.

Now it's possible to work in local space which resolves this issue.

The directional and rotational drive also had an issue where they
would re-enable the rigidbody kinematic state when ungrabbed due to
the default behaviour of the Interactable. This has been configured
to never emit the rigidbody kinematic change events for either drive
as they should not be changing the kinematic states.

The Interactable Consumer Rigidbody can also now be null and the
relevant code that uses it will perform a null check. This won't
work for nested interactables because there will be no collision
catch rigidbody, however if a non-nested interactable is required
without a kinematic rigidbody, then this should allow for that.
  • Loading branch information...
thestonefox committed Apr 8, 2019
1 parent 2b97b73 commit 307ae81089bf085c353747d0ed97c9372e340930

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -4,6 +4,7 @@
using Malimbe.XmlDocumentationAttribute;
using Malimbe.PropertySerializationAttribute;
using Malimbe.BehaviourStateRequirementMethod;
using Zinnia.Extension;
using Zinnia.Data.Type;
using Zinnia.Data.Attribute;
using Zinnia.Tracking.Modification;
@@ -62,11 +63,14 @@ public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
/// <inheritdoc />
public override void ProcessDriveSpeed(float driveSpeed, bool moveToTargetValue)
PropertyApplier.TransitionDuration = 1f / driveSpeed;
PropertyApplier.TransitionDuration = driveSpeed.ApproxEquals(0f) ? 0f : 1f / driveSpeed;
PropertyApplier.enabled = moveToTargetValue;
if (PropertyApplier.enabled)
Interactable.ConsumerRigidbody.velocity =;
if (Interactable.ConsumerRigidbody != null)
Interactable.ConsumerRigidbody.velocity =;
@@ -80,8 +84,9 @@ protected override Transform GetDriveTransform()
/// <inheritdoc />
protected override void SetDriveTargetValue(Vector3 targetValue)
autoDrivePosition.UseLocalValues = true;
autoDrivePosition.Transform = GetDriveTransform();
autoDrivePosition.PositionOverride = autoDrivePosition.Transform.TransformPoint(targetValue - autoDrivePosition.Transform.localPosition);
autoDrivePosition.PositionOverride = targetValue;
PropertyApplier.Source = autoDrivePosition;
@@ -243,10 +243,10 @@ protected virtual void ConfigureGrabOffset()
/// <inheritdoc />
protected override void OnAfterGrabSetupChange()
IsConsumerRigidbodyKinematic = GrabSetup.Facade.ConsumerRigidbody.isKinematic;
IsConsumerRigidbodyKinematic = GrabSetup.Facade.ConsumerRigidbody != null ? GrabSetup.Facade.ConsumerRigidbody.isKinematic : false;
ObjectFollower.Targets.RunWhenActiveAndEnabled(() => ObjectFollower.Targets.Clear());
ObjectFollower.Targets.RunWhenActiveAndEnabled(() => ObjectFollower.Targets.Add(GrabSetup.Facade.ConsumerContainer));
VelocityApplier.Target = GrabSetup.Facade.ConsumerRigidbody;
VelocityApplier.Target = GrabSetup.Facade.ConsumerRigidbody != null ? GrabSetup.Facade.ConsumerRigidbody : null;

/// <summary>
@@ -283,6 +283,11 @@ protected virtual void OnAfterGrabOffsetChange()
protected virtual void OnAfterConsumerRigidbodyIsKinematicChange()
if (GrabSetup.Facade.ConsumerRigidbody == null)

GrabSetup.Facade.ConsumerRigidbody.isKinematic = IsConsumerRigidbodyKinematic;

0 comments on commit 307ae81

Please sign in to comment.
You can’t perform that action at this time.