Last active
August 29, 2015 14:03
-
-
Save nasser/bbe722d55354fd53ea3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using clojure.lang; | |
| using System; | |
| using UnityEngine; | |
| public override object invoke (object obj) | |
| { | |
| object obj2 = PathFollowerUnity$PathFollower_Update__32.__interop_state34 (obj); | |
| object obj3 = ((object[])obj2) [(int)Time.time]; | |
| object obj4 = ((object[])obj2) [(int)( + (double)Time.time)]; | |
| object component = ((Component)obj).GetComponent<Transform> (); | |
| object result; | |
| ((Transform)component).localPosition = (Vector3)(result = Vector3.Lerp ((Vector3)obj3, (Vector3)obj4, (float)Numbers.remainder ((double)Time.time, ))); | |
| return result; | |
| } |
This file contains hidden or 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
| using System; | |
| using UnityEngine; | |
| private void Update () | |
| { | |
| Vector3 from = this.state [(int)Time.time]; | |
| Vector3 to = this.state [(int)Time.time + ]; | |
| base.GetComponent<Transform> ().localPosition = Vector3.Lerp (from, to, Time.time - (float)((int)Time.time)); | |
| } |
This file contains hidden or 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
| (ns PathFollowerUnity | |
| (:import | |
| (UnityEngine Transform Debug GUILayout) | |
| (PathFollowerUnity PathFollower))) | |
| (set! *unchecked-math* true) | |
| (gen-class | |
| :name PathFollowerUnity.PathFollower | |
| :methods [ | |
| [Update [] void]] | |
| :main false | |
| :extends UnityEngine.MonoBehaviour | |
| :prefix "PathFollower-" | |
| :init init | |
| :state state) | |
| (defn PathFollower-init [] [[] (into-array System.Object (vec (repeatedly 1000 #(Vector3. (rand-int 30) (rand-int 18) 0))))]) | |
| (defn PathFollower-Update [^UnityEngine.Component self] | |
| (let [^objects ary (.state self) | |
| ^object current-pos (aget ary Time/time) | |
| ^object next-pos (aget ary (+ 1.0 Time/time)) | |
| ^UnityEngine.Transform transform (. self GetComponent (type-args UnityEngine.Transform))] | |
| (set! (.localPosition transform) | |
| (Vector3/Lerp | |
| current-pos | |
| next-pos | |
| (rem Time/time 1))))) |
This file contains hidden or 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
| using UnityEngine; | |
| using System.Collections; | |
| public class PathFollowerCSharp : MonoBehaviour { | |
| Vector3[] state = new Vector3[1000]; | |
| void Start () { | |
| for(int i=0; i<state.Length; i++) { | |
| state[i] = new Vector3( | |
| (int)Random.Range(0, 30), | |
| (int)Random.Range(0, 18), | |
| 0); | |
| } | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| Vector3 currentpos = state[(int)Time.time]; | |
| Vector3 nextpos = state[(int)Time.time+1]; | |
| GetComponent<Transform>().localPosition = Vector3.Lerp( | |
| currentpos, | |
| nextpos, | |
| (Time.time - (int)Time.time)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment