Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. //--------------------------------------------------------------
  2. // _______ _____ __ ________
  3. // | ___ \ / \ | | |___ ___|
  4. // | | \ | / ___ \ | | / /
  5. // | |___/ / / / \ \ | | / /_
  6. // | | \ \ \ \___/ / | | /_ /
  7. // | |___/ | \ / | |____ | /
  8. // |_______/ \_____/ |_______| |/
  9. //
  10. // V I S U A L S C R I P T I N G
  11. //--------------------------------------------------------------
  12. //
  13. // THIS FILE IS AUTO-GENERATED.
  14. //
  15. // ANY CHANGES WILL BE LOST NEXT TIME THIS SCRIPT IS GENERATED.
  16. //
  17. //--------------------------------------------------------------
  18. #pragma warning disable 162, 219, 429
  19.  
  20. using Bolt;
  21. using Ludiq;
  22. using System;
  23. using System.Collections;
  24. using System.Collections.Generic;
  25. using System.Linq;
  26. using UnityEngine;
  27.  
  28. namespace Bolt.Generated
  29. {
  30. public class AimGraphScript : FlowGraphScript
  31. {
  32. private EventHook updateHook;
  33. private Action<EmptyEventArgs> updateHandler;
  34.  
  35. public AimGraphScript(IMachineScript machineScript) : base(machineScript) {}
  36.  
  37. public override FlowGraphData graphData
  38. {
  39. get => _graphData;
  40. set
  41. {
  42. _graphData = value;
  43. }
  44. }
  45.  
  46. public void Update()
  47. {
  48. var result = Camera.main.WorldToScreenPoint(Input.mousePosition);
  49. var output = result - gameObject.transform.position;
  50.  
  51. Variables.Object(gameObject).Set("dir", output);
  52.  
  53. var result2 = Mathf.Atan2(output.ConvertTo<Vector3>().y, output.ConvertTo<Vector3>().x);
  54. var output2 = Mathf.Rad2Deg * result2;
  55.  
  56. Variables.Object(gameObject).Set("angle", output2);
  57.  
  58. var result3 = Quaternion.Euler(0f, 0f, output2.ConvertTo<float>());
  59.  
  60. gameObject.transform.rotation = result3;
  61. }
  62.  
  63. public override void StartListening()
  64. {
  65. updateHook = new EventHook("Update", machineScript);
  66. updateHandler = args => Update();
  67. EventBus.Register(updateHook, updateHandler);
  68. }
  69.  
  70. public override void StopListening()
  71. {
  72. EventBus.Unregister(updateHook, updateHandler);
  73. updateHandler = null;
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement