From 021d54e3aa6d880b86efa6e3e633b1dcf159808d Mon Sep 17 00:00:00 2001 From: BrentDalling Date: Tue, 27 Oct 2015 10:07:22 -0600 Subject: [PATCH] Made better system for platform.3 //Edited 10/27/2015 by Brent Dalling of 404ERRORTEAM //In Edit I introduced a system so that the platform moves only when collided with. This means that the platform will stay in positions until Player is in contact with the platform. //This project file will also need a way for the platform to "reset" after the player is not in contact for x seconds. --- .../Assets/Scripts/2D/Moving Platform/PlatformMover.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/2d platform/2DGameplayTutorialProject/Assets/Scripts/2D/Moving Platform/PlatformMover.js b/2d platform/2DGameplayTutorialProject/Assets/Scripts/2D/Moving Platform/PlatformMover.js index 38e18af..84ee175 100644 --- a/2d platform/2DGameplayTutorialProject/Assets/Scripts/2D/Moving Platform/PlatformMover.js +++ b/2d platform/2DGameplayTutorialProject/Assets/Scripts/2D/Moving Platform/PlatformMover.js @@ -1,9 +1,13 @@ +//Edited 10/27/2015 by Brent Dalling of 404ERRORTEAM +//In Edit I introduced a system so that the platform moves only when collided with. This means that the platform will stay in positions until Player is in contact with the platform. +//This project file will also need a way for the platform to "reset" after the player is not in contact for x seconds. + var targetA : GameObject; var targetB : GameObject; - +var platform : GameObject; var speed : float = 0.1; -function FixedUpdate () { +function OnCollisionEnter (Collision : platform ) { var weight = Mathf.Cos(Time.time * speed * 2 * Mathf.PI) * 0.5 + 0.5; transform.position = targetA.transform.position * weight + targetB.transform.position * (1-weight);