Skip to content

Commit

Permalink
Flippers (#53)
Browse files Browse the repository at this point in the history
* Apparently there was a minor big in my random selecting code.  I don't understand it, really, but apparently at has something to do with Random.Range.  Works now.  Random logo should show when game starts.  Additionally I added a line of code so that, if someone wants to they cane use the code to select a random Logo at will, but it's currently not set up like that.

* Initial implementation of flippers.  I also mucked about with the bumpers in table2 a little.

* Now using a prefab.  Probably needs more than one, though.  left and right paddles have different property values in the inspector and one one side is red and one side is blue.  Makes saving one prefab and propagating changes to all 4 objects very difficult.  Kind of defeats the purpose of the prefab.  Maybe I wasted a lot of time doing the same things over and over?  There might be something we can do in code that remedy that.   Like if(paddle == "left") etc.  I dunno.
Additionally, testing minor changes is made moderately more difficult because the scene you want to load to test them is not the same scene as the one you're making changes to.
  • Loading branch information
fragmental authored and Cheeseness committed Apr 21, 2017
1 parent 2fbab20 commit a801fef
Show file tree
Hide file tree
Showing 10 changed files with 1,290 additions and 11 deletions.
75 changes: 75 additions & 0 deletions Assets/entities/variant-kgunn/Materials/blueTeam_MAT_kgunn.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: blueTeam_MAT_kgunn
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.07099998, g: 0.2510404, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions Assets/entities/variant-kgunn/Materials/redTeam_MAT_kgunn.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: redTeam_MAT_kgunn
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0.102999985, b: 0.102999985, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/entities/variant-kgunn/flipper.fbx
Binary file not shown.
16 changes: 15 additions & 1 deletion Assets/entities/variant-kgunn/flipper.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Assets/scripts/entity/FlipperController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlipperController : MonoBehaviour
{
public float restPosition = 0F;
public float pressedPosition = 45F;
public float flipperStrength = 2000f;
public float flipperDamper = 5f;
public string inputButtonName = "LeftFlipper";
private HingeJoint paddleHingeJoint;

private JointLimits limits;

void Awake (){
GetComponent<HingeJoint>().useSpring = true;
}


void Update (){
JointSpring spring = new JointSpring();

spring.spring = flipperStrength;
spring.damper = flipperDamper;

if (Input.GetButton(inputButtonName))
{
spring.targetPosition = pressedPosition;
}
else
{
spring.targetPosition = restPosition;
}

GetComponent<HingeJoint>().spring = spring;
GetComponent<HingeJoint>().useLimits = true;
limits = GetComponent<HingeJoint>().limits;
limits.min = restPosition;
limits.max = pressedPosition;
GetComponent<HingeJoint>().limits = limits;
}


}
12 changes: 12 additions & 0 deletions Assets/scripts/entity/FlipperController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a801fef

Please sign in to comment.