-
-
Save markdekuijer/cd9ec6eff78bd6e9d2f63cca16874ce3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void OnRelease() | |
{ | |
if (inRange) | |
{ | |
transform.SetParent(task.transform.parent); | |
if (!inversed) | |
{ | |
transform.DOMove(task.FinalTarget.position, movePlacementDuration); | |
transform.DORotate(task.FinalTarget.rotation.eulerAngles, rotatePlacementDuration); | |
} | |
else | |
{ | |
Vector3 targetRot = ReverseObject(); | |
Vector3 difVec = task.FinalTarget.position - transform.position; | |
Vector3 vecToAdd = difVec.normalized * inverseLenght; | |
transform.position += vecToAdd; | |
transform.DOMove(task.FinalTarget.position, movePlacementDuration); | |
transform.DORotate(targetRot, rotatePlacementDuration); | |
} | |
Destroy(GetComponent<Throwable>()); | |
Destroy(GetComponent<InteractableHoverEvents>()); | |
Destroy(GetComponent<Interactable>()); | |
Destroy(GetComponent<VelocityEstimator>()); | |
Destroy(GetComponent<SteamVR_Skeleton_Poser>()); | |
task.PreviouslyUsedObject = gameObject; | |
foreach (Transform child in transform) | |
{ | |
if (child.CompareTag("AdditionallyUsedObj")) | |
{ | |
task.AdditionallyUsedObj = child.gameObject; | |
break; | |
} | |
} | |
foreach (Renderer renderer in materialRenderer) | |
{ | |
renderer.SetPropertyBlock(defaultBlockPreset); | |
} | |
placedAudio.Play(); | |
completed = true; | |
task.OnTaskComplete?.Invoke(gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment