-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #196 #223
Merged
Merged
Issue #196 #223
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a220c76
Issue #196
otaconwow 8b977c8
Issue #196
otaconwow 803126e
Remoção do for na função Move.
otaconwow fb7d469
Proposta de reparar o Bird coroutine e editor (#1)
StefanWerW f784205
Remoção da variável moveCoroutine
otaconwow b69ba4b
Adding debug info.
otaconwow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEditor; | ||
|
||
[CustomEditor(typeof(MoveAtoB))] | ||
public class BirdEditor : Editor | ||
{ | ||
SerializedProperty pointA_SP; | ||
SerializedProperty pointB_SP; | ||
|
||
public void OnEnable() | ||
{ | ||
pointA_SP = serializedObject.FindProperty("pointA"); | ||
pointB_SP = serializedObject.FindProperty("pointB"); | ||
} | ||
public void OnSceneGUI() | ||
{ | ||
serializedObject.Update(); | ||
MoveAtoB platform = (MoveAtoB)target; | ||
Vector3 pointA = platform.transform.TransformPoint(new Vector3(pointA_SP.vector3Value.x, 0, 0)); | ||
|
||
Handles.color = Color.blue; | ||
|
||
Vector3 pointB = platform.transform.TransformPoint(new Vector3(pointB_SP.vector3Value.x, 0, 0)); | ||
|
||
Handles.color = Color.blue; | ||
pointB = Handles.FreeMoveHandle( | ||
pointB, | ||
Quaternion.identity, | ||
HandleUtility.GetHandleSize(pointB) * 0.08f, | ||
Vector3.one * 0.1f, | ||
Handles.DotCap); | ||
|
||
pointB_SP.vector3Value = platform.transform.InverseTransformPoint(pointB); | ||
Handles.DrawDottedLine(pointA, pointB, 20f); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using System.Collections; | ||
|
||
public class MoveAtoB : MonoBehaviour { | ||
|
||
private Vector3 pointA; | ||
[SerializeField]private Vector3 pointB = new Vector3(2,0,0); | ||
|
||
[Range(0.0f, 20.0f)]public float speed = 2f; | ||
|
||
void Awake () { | ||
pointA = new Vector3(transform.position.x, transform.position.y, transform.position.z); | ||
pointB = transform.TransformPoint(pointB); | ||
} | ||
|
||
void Update() { | ||
// based on the speed set movement step | ||
float step = speed * Time.deltaTime; | ||
// move GameObject from current position (GameObject own position or if defined point A position) to point B | ||
transform.position = Vector3.MoveTowards(transform.position, pointB, step); | ||
} | ||
public class MoveAtoB : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private Vector3 pointA; | ||
[SerializeField] | ||
private Vector3 pointB = new Vector3(2, 0, 0); | ||
[Range(0.0f, 20.0f)] | ||
public float speed = 2f; | ||
void Awake() | ||
{ | ||
pointA = new Vector3(transform.position.x, transform.position.y, transform.position.z); | ||
pointB = transform.TransformPoint(pointB); | ||
} | ||
void FixedUpdate() | ||
{ | ||
StartCoroutine(Move()); | ||
} | ||
IEnumerator Move() | ||
{ | ||
for (float f = 1f; f >= 0; f -= 0.1f) | ||
{ | ||
// based on the speed set movement step | ||
float step = speed * Time.deltaTime; | ||
// move GameObject from current position (GameObject own position or if defined point A position) to point B | ||
transform.position = Vector3.MoveTowards(transform.position, pointB, step); | ||
yield return null; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por que esse
for
? Pq ele executa só 10 vezes? Como sabe que ja chegou no target pra parar de rodar o Coroutine?Nao seria melhor um
while
que verifica se a distancia atual pro target é pequena, ou zero?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StefanWerW Pode ser, eu apenas mantive a lógica que havia sido implementada inicialmente. Vou fazer os testes da forma que você falou e faço a alteração. :)