Commit bfd0730a authored by Matthew Woods's avatar Matthew Woods
Browse files

Added Dino Rotation

Dino Rotation
parent 59a007aa
fileFormatVersion: 2
guid: a6e7c725916d1194b8eee17c66ed7e9a
timeCreated: 1450522380
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -13,31 +13,37 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Animcount
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: LegBlend
m_Type: 1
m_DefaultFloat: .5
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IdlePose
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IdleIndex
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Angle
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
......
......@@ -13,25 +13,31 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Animcount
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: LegBlend
m_Type: 1
m_DefaultFloat: .5
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IdleIndex
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Angle
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
......
......@@ -13,31 +13,37 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Animcount
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: LegBlend
m_Type: 1
m_DefaultFloat: .5
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IdlePose
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IdleIndex
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Angle
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
......
......@@ -39,7 +39,7 @@ namespace UniOSC{
UnityEngine.Cursor.visible = false;
//Initial Dinosaur to Control (increments in update function)
i = 1;
i = 0;
}
......@@ -75,12 +75,11 @@ namespace UniOSC{
X = (float)((OscMessage)args.Packet).Data[0] ;
Y = (float)((OscMessage)args.Packet).Data[1] ;
Z = (float)((OscMessage)args.Packet).Data[2] ;
//Debug.Log("X: " + X);
dinos[i].reset = true;
dinos[i].reset = false;
dinos[i].turn = X*10F;
dinos[i].pitch = Y*14F-3F;
dinos[i].SetTarget(dinoIn[i].position,X,Z);
dinos[i].SetTarget(dinoIn[i].position,X,Z,false);
/*if (Z < 0.4 && Z > -0.4) {
rexPup.speed = 0;
......@@ -101,35 +100,26 @@ namespace UniOSC{
dinos[i].open = -45F*(Mathf.Clamp01((0.6F-Grab)*2F));
}
//Debug.Log ("OnOSCMessageRecieved");
}
void Update ()
{
dinos[i].reset = true;
/*dinos[i].turn = X*10F;
dinos[i].pitch = Y*14F-3F;
dinos[i].SendMessage ("SetTarget",dinoIn[i].position);*/
if (puppetActive) {
if (Time.time > timestamp + 0.1F) {
dinos [i].reset = true;
}
if (Time.time > timestamp + 2F) {
dinos [i].SetTarget(dinoOut [i].position,0,0);
dinos [i].SetTarget(dinoOut [i].position,0,0,true);
//i++; --> Increments to next dino
i++; //--> Increments to next dino
/*if (i == 3) {
i = 0;
} else if (i == 0) {
i = 3;
}*/
if (i == numDinos)
i = 0;*/
if (i == numDinos)
i = 0;
puppetActive = false;
}
......
......@@ -68,6 +68,7 @@ public class brachpuppet_cs : dinopuppet_cs
void Update ()
{
if (reset) Reset();
anim.SetFloat ("Speed", agent.velocity.magnitude/8);
......@@ -128,7 +129,8 @@ public class brachpuppet_cs : dinopuppet_cs
{
standardUpdate ();
balance = Mathf.Clamp(balance, -10.0F, 10.0F);
open = Mathf.Clamp(open, -41.0F, 0.0F);
......
......@@ -6,9 +6,12 @@ using UniOSC;
public class dinopuppet_cs : MonoBehaviour {
public UniOSCDinoPuppetReceiver_cs PuppetReceiver;
public bool reset =false;
public bool reset = false;
public bool leftDino = false;
public float balance, turn, pitch, speed, open = 0.0F;
public float browsingRadius = 4.0F;
public float browsingAngle = 60.0F;
protected float initAngle = 0.0F;
protected NavMeshAgent agent;
......@@ -18,6 +21,7 @@ public class dinopuppet_cs : MonoBehaviour {
public AudioClip[] roar;
protected AudioSource source;
protected Animator anim;
private Vector3 oldTarget;
// Use this for initialization
void Awake ()
......@@ -28,14 +32,18 @@ public class dinopuppet_cs : MonoBehaviour {
void Start () {
myTransform = this.transform;
initAngle = myTransform.localEulerAngles.y;
agent = GetComponent<NavMeshAgent> ();
source = GetComponent<AudioSource>();
anim = GetComponent<Animator>();
oldTarget = new Vector3 (0F, 0F, 0F);
}
public void Reset () {
oldTarget = new Vector3 (0F, 0F, 0F);
if (turn != 0.0F || pitch != 0.0F || open != 0.0F) {
if (turn < 0.0F) {
......@@ -70,16 +78,12 @@ public class dinopuppet_cs : MonoBehaviour {
}
void FixedUpdate ()
{
public void standardUpdate () {
if (agent.velocity.magnitude > 0) {
angle = myTransform.InverseTransformDirection(agent.velocity).x;
anim.SetFloat ("Angle", angle);
balance = -angle*1.5F;
}
else {
balance = 0.0F;
......@@ -87,17 +91,35 @@ public class dinopuppet_cs : MonoBehaviour {
}
public void SetTarget (Vector3 Target, float X, float Z){
Debug.Log (myTransform.TransformPoint (X, 0.0F, Z));
if (agent.remainingDistance < 2) {
if (new Vector2 (X, Z).magnitude > 0.5F) {
Vector3 Browsevector = new Vector3(X * browsingRadius, 0, Z * browsingRadius);
agent.destination = myTransform.TransformPoint(Browsevector);
} else {
public void SetTarget (Vector3 Target, float X, float Z, bool RotBool){
if (Target == oldTarget) {
if (agent.hasPath == false) {
//Debug.Log("hello"&& agent.remainingDistance);
if (Mathf.Abs (X) > 0.65F) {
float diffY = Mathf.DeltaAngle(myTransform.localEulerAngles.y, initAngle);
Debug.Log("diffY:"+diffY);
if ((diffY>0&&X>0)||(diffY<0&&X<0)||(diffY>0 && diffY<browsingAngle)||(diffY<0 && diffY>-browsingAngle)){
Vector3 Browsevector = new Vector3 (X * browsingRadius, 0, Z * browsingRadius);
Vector3 Browsepoint = myTransform.TransformPoint (Browsevector);
agent.destination = Browsepoint;
}
}
}
}
else {
oldTarget = Target;
agent.destination = Target;
}
}
}
public void Roar ()
......
......@@ -63,6 +63,8 @@ public class ovipuppet_cs : dinopuppet_cs
void Update ()
{
if (reset) Reset();
anim.SetFloat ("Speed", agent.velocity.magnitude/20);
......@@ -114,7 +116,8 @@ public class ovipuppet_cs : dinopuppet_cs
//Clamp and set bone rotations
void LateUpdate()
{
standardUpdate ();
balance = Mathf.Clamp (balance, -7.5F, 7.5F);
if (anim.GetNextAnimatorStateInfo (0).IsName ("Ovi|Run") ||
......
......@@ -49,6 +49,7 @@ public class rexpuppet_cs : dinopuppet_cs
void Update ()
{
if (reset) Reset();
anim.SetFloat ("Speed", agent.velocity.magnitude/15);
......@@ -118,6 +119,8 @@ public class rexpuppet_cs : dinopuppet_cs
//Clamp and set bone rotations
void LateUpdate()
{
standardUpdate ();
balance = Mathf.Clamp(balance, -11.0F, 11.0F);
turn = Mathf.Clamp(turn, -12.0F, 12.0F);
......
......@@ -58,7 +58,6 @@ public class tripuppet_cs : dinopuppet_cs
{
if (reset) Reset();
anim.SetFloat ("Speed", agent.velocity.magnitude/8);
......@@ -130,7 +129,9 @@ public class tripuppet_cs : dinopuppet_cs
//Clamp and set bone rotations
void LateUpdate()
{
standardUpdate ();
balance = Mathf.Clamp(balance, -4.0F, 4.0F);
open = Mathf.Clamp(open, -20.0F, 0.0F);
turn = Mathf.Clamp (turn, -15.0F, 15.0F);
......
This diff is collapsed.
fileFormatVersion: 2
guid: bb8885e90502e4b41bfcf57d297a0c3b
timeCreated: 1456199589
licenseType: Free
guid: 5a1aeee9f90784fda9bcaa3bc5cacb00
timeCreated: 1464106527
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
......
fileFormatVersion: 2
guid: ab89d7e9dbd9462458ecef029ee60f6e
timeCreated: 1464105343
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
......@@ -14,7 +16,7 @@ TextureImporter:
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
externalNormalMap: 1
heightScale: .25
normalMapFilter: 0
isReadable: 0
......@@ -35,6 +37,7 @@ TextureImporter:
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
......@@ -43,10 +46,11 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
textureType: 1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
......@@ -11,5 +11,7 @@ EditorBuildSettings:
path: Assets/Scenes/RayDinos_Tree.unity
- enabled: 0
path: Assets/Scenes/DinosWalkInAndOut.unity
- enabled: 1
- enabled: 0
path: Assets/Scenes/Demo_4-29.unity
- enabled: 1
path: Assets/Scenes/DinosWalkInAndOutMatt.unity
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment