├── README.md ├── Classes ├── Readme.md ├── EnnemiBehaviour │ ├── BasicEnnemiBehaviourHolder.cs │ ├── StochasticBehaviour.cs │ ├── BasicEnnemiBehaviour.cs │ ├── Readme.md │ ├── BasicEnnemiControl.cs │ ├── BasicEnnemi.cs │ └── BasicEnnemiSubBehaviour.cs ├── Detector.cs ├── Gun.cs ├── UtilityNode.cs ├── UtilityMap.cs └── GradientNavigation.cs ├── QuickAnimation ├── Hits │ ├── Readme.md │ ├── BoxerPunch1 │ └── BoxerPunch2 ├── Animations │ ├── Hits │ │ ├── Readme.md │ │ ├── BoxerJab │ │ ├── BoxerHookL │ │ ├── BoxerHookR │ │ ├── BoxerPunch1 │ │ ├── BoxerPunch2 │ │ ├── BoxerUpperL │ │ ├── BoxerUpperR │ │ ├── SanHitPunch │ │ ├── SanHitSalto │ │ ├── SanImpact1 │ │ ├── BoxerDodgeLeft │ │ ├── BoxerHitDirect │ │ ├── KratosHeadButt │ │ ├── KratosHitDash │ │ ├── SanFrontKick │ │ ├── SanHitJumpFoot │ │ ├── SanImpactBelly │ │ ├── SanImpactHead │ │ ├── BoxerDodgeRight │ │ ├── KratosHitDirect │ │ └── SanRotatingKick │ ├── Jumps │ │ ├── Readme.md │ │ ├── SanDoubleJump │ │ ├── KratosJumpFull │ │ ├── SanRecoverToRun │ │ ├── KratosRecoverToRun │ │ ├── SanRecoverToIdle │ │ ├── KratosRecoverToRoll │ │ └── SanCompleteJumpCycle │ ├── Runs │ │ ├── Readme.md │ │ ├── Run │ │ ├── SanRun │ │ ├── BoxerRun │ │ ├── RunBoxer │ │ ├── SanDash │ │ ├── SanFastRun │ │ ├── BoxerDashLeft │ │ ├── BoxerDashRight │ │ ├── BoxerWalkRight │ │ ├── KratosSprint │ │ ├── BoxerDashForward │ │ ├── BoxerWalkForward │ │ └── BoxerDashBackward │ ├── Idles │ │ ├── Readme.md │ │ ├── BoxerIdle │ │ ├── KratosIdle │ │ └── SanIdleCombat │ └── Readme.md ├── Readme.md └── BoneFollow.py ├── SkatingGame ├── Readme.md ├── InputProcessing.cs ├── CameraSkate.cs ├── SkateAnim.cs └── SkateControl.cs ├── GlobalBaseScripts ├── Readme.md ├── BaseInputs.cs ├── BaseInformModular.cs ├── BaseHitInfo.cs ├── BaseStatesReset.cs ├── BaseSpecificTimeInformModular.cs ├── BaseHitImpact.cs ├── BaseModular.cs └── BaseFight.cs ├── BoxingGame ├── BoxerAnim 5.fbx ├── Readme.md ├── RingPonctualInfo.cs ├── ControlRing.cs ├── RingResetState.cs ├── InputsBoxer.cs ├── RingDodgeInfo.cs ├── CamBoxer.cs ├── RingContinuousInfos.cs ├── RingHitInfo.cs ├── BoxerModularController.cs ├── RingHitImpact.cs ├── BoxerFightController.cs ├── BoxerMoveController.cs └── AIProto3.cs ├── ModularController ├── SanAnim.fbx ├── Readme.md ├── ShootParticles.cs ├── ResetState.cs ├── SwitchOnState.cs ├── SendInformationsContinuous.cs ├── SendInformations.cs ├── ModularController.cs ├── ParticlesBehaviour.cs ├── HitImpact.cs ├── FightModule.cs └── MoveModule.cs ├── BlenderRigForUnity ├── initial_pose ├── F-curves Saver │ ├── test_save.py │ ├── Readme.md │ ├── test_load.py │ ├── Saver.py │ ├── Loader.py │ └── BasicHuma.py └── Readme.md ├── God of War- ReMehd ├── GoWValues.png ├── GoWCommon.cs ├── GoWInputs.cs ├── GoWCamIsom.cs ├── GoWCam.cs ├── InformModular.cs ├── HitInfo.cs ├── StatesReset.cs ├── SpecificTimeInformModular.cs ├── GoWHitImpact.cs ├── Readme.md ├── GoWModular.cs ├── GoWAxeControl.cs └── GoWFight.cs ├── DecisionTreeEditor ├── node_black.png ├── node_green.png ├── node_orange.png ├── Readme.md ├── node_black_bigger.png ├── TestDecisionTree.cs ├── TestExploDT.cs └── DTFromCustom.asset ├── GrassUtility ├── Readme.md ├── GrassPatches.cs ├── GrassDisperser.cs └── GrassPointCloudRenderer.cs ├── 2.5DController ├── Readme.md ├── ResetState.cs ├── ResetStates.cs ├── SwitchOnState.cs ├── JumpControl.cs ├── SendInformationsContinuous.cs ├── SendInformations.cs ├── ModularController.cs ├── Inputs2B.cs ├── HitImpact.cs └── FightModule.cs ├── ReCompileCubes ├── Readme.md └── TestRotation.cs ├── AnthemController ├── Readme.md ├── AnimationState.cs ├── Impulsion.cs ├── CharacterStates.cs ├── DelayedImpulsion.cs ├── PersoFillerShooter.cs ├── ShooterController.cs ├── TPSCam.cs └── NamedEffect.cs ├── Controller ├── AnimationState.cs ├── CharacterStates.cs ├── Impulsion.cs ├── ProjectileBehav.cs ├── PersoFiller.cs ├── Readme.md ├── TPSCam.cs └── ControlCharacter.cs └── GhostOfTsushimaController ├── AttackHitBox.cs ├── AnimationState.cs ├── Readme.md ├── HitBox.cs ├── CharacterStates.cs ├── DelayedImpulsion.cs ├── FightingStateBehaviour.cs ├── SamuraiController.cs ├── ImpulsionHolder.cs ├── SamuraiFiller.cs └── NamedEffect.cs /README.md: -------------------------------------------------------------------------------- 1 | # Unity -------------------------------------------------------------------------------- /Classes/Readme.md: -------------------------------------------------------------------------------- 1 | # Classes Unity 2 | -------------------------------------------------------------------------------- /QuickAnimation/Hits/Readme.md: -------------------------------------------------------------------------------- 1 | # Hits animations 2 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/Readme.md: -------------------------------------------------------------------------------- 1 | # Hits animations 2 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/Readme.md: -------------------------------------------------------------------------------- 1 | # Jump animations 2 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/Readme.md: -------------------------------------------------------------------------------- 1 | # Run animations 2 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Idles/Readme.md: -------------------------------------------------------------------------------- 1 | # Standby animations 2 | -------------------------------------------------------------------------------- /SkatingGame/Readme.md: -------------------------------------------------------------------------------- 1 | # Scripts for my upcoming great SKATING GAME ! 2 | 3 | -------------------------------------------------------------------------------- /GlobalBaseScripts/Readme.md: -------------------------------------------------------------------------------- 1 | # Base scripts for thrid person controller 2 | 3 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Readme.md: -------------------------------------------------------------------------------- 1 | # Saved animation files using Rigify module 2 | -------------------------------------------------------------------------------- /BoxingGame/BoxerAnim 5.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/BoxingGame/BoxerAnim 5.fbx -------------------------------------------------------------------------------- /ModularController/SanAnim.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/ModularController/SanAnim.fbx -------------------------------------------------------------------------------- /BlenderRigForUnity/initial_pose: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/BlenderRigForUnity/initial_pose -------------------------------------------------------------------------------- /God of War- ReMehd/GoWValues.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/God of War- ReMehd/GoWValues.png -------------------------------------------------------------------------------- /QuickAnimation/Hits/BoxerPunch1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Hits/BoxerPunch1 -------------------------------------------------------------------------------- /QuickAnimation/Hits/BoxerPunch2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Hits/BoxerPunch2 -------------------------------------------------------------------------------- /DecisionTreeEditor/node_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/DecisionTreeEditor/node_black.png -------------------------------------------------------------------------------- /DecisionTreeEditor/node_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/DecisionTreeEditor/node_green.png -------------------------------------------------------------------------------- /DecisionTreeEditor/node_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/DecisionTreeEditor/node_orange.png -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/Run: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/Run -------------------------------------------------------------------------------- /BoxingGame/Readme.md: -------------------------------------------------------------------------------- 1 | # Scripts and logic for the boxing game 2 | 3 | See: https://www.youtube.com/watch?v=FTYuMBSOfEM 4 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/SanRun: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/SanRun -------------------------------------------------------------------------------- /DecisionTreeEditor/Readme.md: -------------------------------------------------------------------------------- 1 | # A custom editor window for generating scriptable object from the DecisionTree class 2 | 3 | -------------------------------------------------------------------------------- /DecisionTreeEditor/node_black_bigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/DecisionTreeEditor/node_black_bigger.png -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerJab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerJab -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerRun: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerRun -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/RunBoxer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/RunBoxer -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/SanDash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/SanDash -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerHookL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerHookL -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerHookR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerHookR -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerPunch1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerPunch1 -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerPunch2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerPunch2 -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerUpperL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerUpperL -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerUpperR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerUpperR -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanHitPunch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanHitPunch -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanHitSalto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanHitSalto -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanImpact1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanImpact1 -------------------------------------------------------------------------------- /QuickAnimation/Animations/Idles/BoxerIdle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Idles/BoxerIdle -------------------------------------------------------------------------------- /QuickAnimation/Animations/Idles/KratosIdle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Idles/KratosIdle -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/SanFastRun: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/SanFastRun -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerDodgeLeft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerDodgeLeft -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerHitDirect: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerHitDirect -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/KratosHeadButt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/KratosHeadButt -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/KratosHitDash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/KratosHitDash -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanFrontKick: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanFrontKick -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanHitJumpFoot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanHitJumpFoot -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanImpactBelly: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanImpactBelly -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanImpactHead: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanImpactHead -------------------------------------------------------------------------------- /QuickAnimation/Animations/Idles/SanIdleCombat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Idles/SanIdleCombat -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/SanDoubleJump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/SanDoubleJump -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerDashLeft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerDashLeft -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerDashRight: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerDashRight -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerWalkRight: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerWalkRight -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/KratosSprint: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/KratosSprint -------------------------------------------------------------------------------- /GrassUtility/Readme.md: -------------------------------------------------------------------------------- 1 | # Grass utilty 2 | 3 | ### Grass shader (geometry) 4 | ### Grass patch (class) 5 | ### Grass disperser (script) 6 | -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/BoxerDodgeRight: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/BoxerDodgeRight -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/KratosHitDirect: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/KratosHitDirect -------------------------------------------------------------------------------- /QuickAnimation/Animations/Hits/SanRotatingKick: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Hits/SanRotatingKick -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/KratosJumpFull: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/KratosJumpFull -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/SanRecoverToRun: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/SanRecoverToRun -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerDashForward: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerDashForward -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerWalkForward: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerWalkForward -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/KratosRecoverToRun: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/KratosRecoverToRun -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/SanRecoverToIdle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/SanRecoverToIdle -------------------------------------------------------------------------------- /QuickAnimation/Animations/Runs/BoxerDashBackward: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Runs/BoxerDashBackward -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/KratosRecoverToRoll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/KratosRecoverToRoll -------------------------------------------------------------------------------- /QuickAnimation/Animations/Jumps/SanCompleteJumpCycle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoMe36/Unity/HEAD/QuickAnimation/Animations/Jumps/SanCompleteJumpCycle -------------------------------------------------------------------------------- /2.5DController/Readme.md: -------------------------------------------------------------------------------- 1 | # A 2.5D unity controller. 2 | 3 | Improvements: 4 | 5 | * Better physics 6 | * More responsive 7 | * Double jump 8 | * Dash 9 | * One animation cycle jump 10 | -------------------------------------------------------------------------------- /ReCompileCubes/Readme.md: -------------------------------------------------------------------------------- 1 | # Recompile 2 | 3 | Mesh effects inspired from Recompile: 4 | https://www.gamasutra.com/blogs/PhiDinh/20180523/318444/Game_Design_Deep_Dive_Rendering_the_player_as_a_form_of_pure_energy_in_Recompile.php 5 | -------------------------------------------------------------------------------- /AnthemController/Readme.md: -------------------------------------------------------------------------------- 1 | # Alternative controller for Unity similar to God of War/ Anthem style 2 | 3 | ## Available states: 4 | * Idle/Move 5 | * Jump 6 | * Fly 7 | * Superfly 8 | 9 | ## TODO 10 | * Hit 11 | * Shoot 12 | -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/BasicEnnemiBehaviourHolder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BasicEnnemiBehaviourHolder : MonoBehaviour { 6 | 7 | public BasicEnnemiBehaviour Behaviour; 8 | } 9 | -------------------------------------------------------------------------------- /BoxingGame/RingPonctualInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingPonctualInfo : MonoBehaviour { 6 | 7 | // Use this for initialization 8 | void Start () { 9 | 10 | } 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Controller/AnimationState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class AnimationState { 7 | 8 | public string name; 9 | public bool state; 10 | 11 | public AnimationState (string s) 12 | { 13 | name = s; 14 | state = false; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/AttackHitBox.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class AttackHitBox : MonoBehaviour { 6 | 7 | public Transform TargetPosition; 8 | public List ActiveStates = new List(); 9 | [HideInInspector] 10 | public bool Active = false; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /BoxingGame/ControlRing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ControlRing : MonoBehaviour { 6 | 7 | // Use this for initialization 8 | void Start () { 9 | 10 | } 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | // Move only with dash ! 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AnthemController/AnimationState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class AnimationState { 7 | 8 | public string name; 9 | public bool state; 10 | 11 | public AnimationState (string s) 12 | { 13 | name = s; 14 | state = false; 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/test_save.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from Saver import * 3 | from BasicHuma import Humanoid 4 | 5 | 6 | print('\n'*100) 7 | path = '/home/mehdi/Blender/Scripts/FcurvesSL/Hook' 8 | 9 | armature = Humanoid(bpy.data.objects['Armature']) 10 | curves = armature.get_curves() 11 | 12 | saver = StructureSaver('newtest', curves, armature) 13 | 14 | saver.save(path) -------------------------------------------------------------------------------- /GhostOfTsushimaController/AnimationState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class AnimationState { 7 | 8 | public string name; 9 | public bool state; 10 | 11 | public AnimationState (string s) 12 | { 13 | name = s; 14 | state = false; 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/StochasticBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class StochasticBehaviour 7 | { 8 | public float Probability; 9 | public string Action; 10 | 11 | 12 | public StochasticBehaviour(float p, string s) 13 | { 14 | Probability = p; 15 | Action = s; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/Readme.md: -------------------------------------------------------------------------------- 1 | # F-Curve saver 2 | This new version allows support for bones that are not part of BasicHuma. 3 | 4 | Major point of interest: include weapons for instance, tails or whatever. 5 | Two restrictions: 6 | * Make sure to name your external bones by beginning by "other" otherwise, scripts will break. Example: other_sword, otherGun, other_Tail1... 7 | * The script does not record the curves for the weapons, only the body is taken into account. However, this still is interesting. 8 | -------------------------------------------------------------------------------- /ModularController/Readme.md: -------------------------------------------------------------------------------- 1 | # Best controller so far 2 | 3 | While still in 2D, just a few things would need to evolve in order to upgrade to 3D. 4 | 5 | Good thing is that the controller in now modular: 6 | 7 | * ModularController ties it all 8 | * MoveModule for Run, Dash (jump to come) 9 | * FightController + HitImpact for fighting purposes 10 | 11 | Also, recently discovered StateBehaviours, which is such a great thing ! 12 | This controller relies hence also on a few scripts derived from StateMachineBehaviours 13 | 14 | -------------------------------------------------------------------------------- /Controller/CharacterStates.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class CharacterStates 7 | { 8 | public string Name; 9 | public List Correspondances = new List(); 10 | public bool Passive; 11 | [HideInInspector] 12 | public bool Current; 13 | 14 | public CharacterStates(string n, List s, bool p, bool c) 15 | { 16 | Name = n; 17 | Correspondances = s; 18 | Passive = p; 19 | Current = c; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ModularController/ShootParticles.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ShootParticles : MonoBehaviour { 6 | 7 | public GameObject PrefabParticle; 8 | 9 | // Use this for initialization 10 | void Start () { 11 | 12 | } 13 | 14 | // Update is called once per frame 15 | public void Shoot(Transform t) 16 | { 17 | GameObject p = Instantiate(PrefabParticle, transform.position, PrefabParticle.transform.rotation) as GameObject; 18 | p.GetComponent().SetShooter(t); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SkatingGame/InputProcessing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public class InputProcessing : MonoBehaviour { 7 | 8 | public float X; 9 | public float Y; 10 | 11 | 12 | // Use this for initialization 13 | void Start () { 14 | 15 | 16 | 17 | } 18 | 19 | // Update is called once per frame 20 | void Update () { 21 | 22 | X = Input.GetAxis("Horizontal"); 23 | Y = Input.GetAxis("Vertical"); 24 | 25 | } 26 | 27 | 28 | public Vector2 GetDirection() 29 | { 30 | return new Vector2(X,Y); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /GhostOfTsushimaController/Readme.md: -------------------------------------------------------------------------------- 1 | # Controller based on Ghost of Tsushima preview 2 | 3 | Basic controller for fighting games. WIP 4 | 5 | 6 | 1. Add SamuraiController to a character 7 | 1. It uses SamuraiFiller for holding all the data 8 | 1. A very important class is AnimationStates: holds names and states of triggers. Use `Activate("name_of_the_state")` to launch an animation. 9 | 1. Another one is CharacterStates, which carries states defined by names, and animation correspondances. Beware of spelling mistakes when defining correspondances. Also, precise passive states (in contrast with ponctual actions) and fighting states. 10 | 1. Make sure to add the FightingBehaviourScript for all fighting states, responsible to turning ExitBool to true, for espacing fighting animations. 11 | 1. You can add Effects, Impulsions (useful for jumps) 12 | -------------------------------------------------------------------------------- /DecisionTreeEditor/TestDecisionTree.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestDecisionTree : MonoBehaviour { 6 | 7 | public DecisionTree DecisionModule; 8 | public GSR game_state_representation; 9 | public float customvalue = 0.5f; 10 | 11 | float timer = 0f; 12 | 13 | 14 | 15 | // Use this for initialization 16 | void Start () { 17 | 18 | 19 | // Debug.Log(DecisionModule.ToString()); 20 | } 21 | 22 | // Update is called once per frame 23 | void Update () { 24 | 25 | timer -= Time.deltaTime; 26 | if (timer <=0f) 27 | { 28 | game_state_representation.state[0] = customvalue; 29 | 30 | string result = DecisionModule.Decide(game_state_representation); 31 | Debug.Log(result); 32 | timer = 1; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/BasicEnnemiBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class BasicEnnemiBehaviour 7 | { 8 | public BasicEnnemiSubBehaviour [] Behaviours; 9 | 10 | public BasicEnnemiBehaviour() 11 | { 12 | 13 | } 14 | 15 | 16 | public string SelectAction(float d) 17 | { 18 | 19 | // Select subbehaviour based on distance 20 | int iterator = 0; 21 | int i = 0; 22 | foreach(BasicEnnemiSubBehaviour b in Behaviours) 23 | { 24 | if(d > b.DistanceMin && d < b.DistanceMax) 25 | { 26 | iterator = i; 27 | } 28 | 29 | i++; 30 | } 31 | 32 | 33 | // Select action by sampling 34 | string s = Behaviours[iterator].Sample(); 35 | 36 | return s; 37 | } 38 | 39 | 40 | 41 | 42 | 43 | } -------------------------------------------------------------------------------- /GhostOfTsushimaController/HitBox.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class HitBox : MonoBehaviour { 6 | 7 | public string TargetAnimation = "Impact"; 8 | public bool Active; 9 | 10 | // Use this for initialization 11 | void Start () { 12 | 13 | } 14 | 15 | // Update is called once per frame 16 | void Update () { 17 | 18 | } 19 | 20 | void OnTriggerStay(Collider other) // if problems: switch to OnTriggerStay 21 | { 22 | // Add conditions 23 | if(!(other.transform.root == transform.root)) 24 | { 25 | if(other.GetComponent()) 26 | { 27 | if(other.GetComponent().Active) 28 | { 29 | Active = true; 30 | } 31 | } 32 | } 33 | else 34 | { 35 | Debug.Log("Mine"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Controller/Impulsion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Impulsion 6 | { 7 | public Vector3 Direction; 8 | public float Strengh; 9 | public float Duration; 10 | public bool Active = false; 11 | 12 | float counter = 0.0f; 13 | 14 | public Impulsion(Vector3 v, float f, float d) 15 | { 16 | Direction = v; 17 | Strengh = f; 18 | Duration = d; 19 | 20 | counter = Duration; 21 | Active = true; 22 | } 23 | 24 | public bool Count() 25 | { 26 | if(Active) 27 | { 28 | if(counter > 0) 29 | { 30 | counter -= Time.deltaTime; 31 | } 32 | if (counter < 0) 33 | Active = false; 34 | } 35 | 36 | return Active; 37 | } 38 | 39 | public Vector3 Impulse() 40 | { 41 | return Direction*Strengh; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AnthemController/Impulsion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Impulsion 6 | { 7 | public Vector3 Direction; 8 | public float Strengh; 9 | public float Duration; 10 | public bool Active = false; 11 | 12 | float counter = 0.0f; 13 | 14 | public Impulsion(Vector3 v, float f, float d) 15 | { 16 | Direction = v; 17 | Strengh = f; 18 | Duration = d; 19 | 20 | counter = Duration; 21 | Active = true; 22 | } 23 | 24 | public bool Count() 25 | { 26 | if(Active) 27 | { 28 | if(counter > 0) 29 | { 30 | counter -= Time.deltaTime; 31 | } 32 | if (counter < 0) 33 | Active = false; 34 | } 35 | 36 | return Active; 37 | } 38 | 39 | public Vector3 Impulse() 40 | { 41 | return Direction*Strengh; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /2.5DController/ResetState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ResetState : StateMachineBehaviour { 6 | 7 | public string StateToReset; 8 | public bool OnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | if(OnEnter) 13 | { 14 | SwitchOff(animator); 15 | } 16 | } 17 | 18 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 19 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 20 | if(!OnEnter) 21 | { 22 | SwitchOff(animator); 23 | } 24 | } 25 | 26 | void SwitchOff(Animator animator) 27 | { 28 | animator.SetBool(StateToReset, false); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /ModularController/ResetState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ResetState : StateMachineBehaviour { 6 | 7 | public string StateToReset; 8 | public bool OnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | if(OnEnter) 13 | { 14 | SwitchOff(animator); 15 | } 16 | } 17 | 18 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 19 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 20 | if(!OnEnter) 21 | { 22 | SwitchOff(animator); 23 | } 24 | } 25 | 26 | void SwitchOff(Animator animator) 27 | { 28 | animator.SetBool(StateToReset, false); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Controller/ProjectileBehav.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ProjectileBehav : MonoBehaviour { 6 | 7 | public float Life = 1; 8 | [HideInInspector] 9 | public Vector3 direction = Vector3.one; 10 | public float Speed = 2 ; 11 | 12 | // Use this for initialization 13 | void Start () { 14 | 15 | Destroy(gameObject, Life); 16 | 17 | } 18 | 19 | // Update is called once per frame 20 | void Update () { 21 | 22 | transform.position += direction*Time.deltaTime*Speed; 23 | 24 | } 25 | 26 | public void SetDirection(Vector3 v) 27 | { 28 | direction = v; 29 | } 30 | 31 | void OnTriggerEnter(Collider other) 32 | { 33 | GameObject g = other.gameObject; 34 | Rigidbody rb = g.GetComponent(); 35 | if (rb) 36 | { 37 | rb.AddForce((g.transform.position - transform.position)*1000); 38 | } 39 | 40 | Destroy(gameObject); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /2.5DController/ResetStates.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ResetStates : StateMachineBehaviour { 6 | 7 | public string [] StatesToReset; 8 | public bool OnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | if(OnEnter) 13 | { 14 | SwitchOff(animator); 15 | } 16 | } 17 | 18 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 19 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 20 | if(!OnEnter) 21 | { 22 | SwitchOff(animator); 23 | } 24 | } 25 | 26 | void SwitchOff(Animator animator) 27 | { 28 | foreach(string s in StatesToReset) 29 | { 30 | animator.SetBool(s, false); 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /2.5DController/SwitchOnState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SwitchOnState : StateMachineBehaviour { 6 | 7 | public string Information; 8 | 9 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 10 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 11 | Call(animator, true); 12 | } 13 | 14 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 15 | 16 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 17 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 18 | Call(animator, false); 19 | } 20 | 21 | void Call(Animator animator, bool state) 22 | { 23 | animator.gameObject.GetComponent().Switch(Information, state); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /ModularController/SwitchOnState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SwitchOnState : StateMachineBehaviour { 6 | 7 | public string Information; 8 | 9 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 10 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 11 | Call(animator, true); 12 | } 13 | 14 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 15 | 16 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 17 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 18 | Call(animator, false); 19 | } 20 | 21 | void Call(Animator animator, bool state) 22 | { 23 | animator.gameObject.GetComponent().Switch(Information, state); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /AnthemController/CharacterStates.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class CharacterStates 7 | { 8 | public string Name; 9 | public List Correspondances = new List(); 10 | public bool Passive; 11 | [HideInInspector] 12 | public bool Current; 13 | // [HideInInspector] 14 | // public bool was_changed = false; 15 | // [HideInInspector] 16 | public bool FightingState = false; 17 | 18 | public CharacterStates(string n, List s, bool p, bool c) 19 | { 20 | Name = n; 21 | Correspondances = s; 22 | Passive = p; 23 | Current = c; 24 | } 25 | 26 | public void UnlockPassive() 27 | { 28 | Passive = false; 29 | // Debug.Log("Unlocking " + Name); 30 | // was_changed = true; 31 | } 32 | 33 | public void Reset() 34 | { 35 | // if(was_changed) 36 | // { 37 | // was_changed = false; 38 | Passive = true; 39 | // } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/CharacterStates.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class CharacterStates 7 | { 8 | public string Name; 9 | public List Correspondances = new List(); 10 | public bool Passive; 11 | [HideInInspector] 12 | public bool Current; 13 | // [HideInInspector] 14 | // public bool was_changed = false; 15 | // [HideInInspector] 16 | public bool FightingState = false; 17 | 18 | public CharacterStates(string n, List s, bool p, bool c) 19 | { 20 | Name = n; 21 | Correspondances = s; 22 | Passive = p; 23 | Current = c; 24 | } 25 | 26 | public void UnlockPassive() 27 | { 28 | Passive = false; 29 | // Debug.Log("Unlocking " + Name); 30 | // was_changed = true; 31 | } 32 | 33 | public void Reset() 34 | { 35 | // if(was_changed) 36 | // { 37 | // was_changed = false; 38 | Passive = true; 39 | // } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWCommon.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWCommon : MonoBehaviour { 6 | 7 | static float TimeFactor = 0.01f; 8 | static float StopLength = 0.2f; 9 | static float stop_length_counter = 0f; 10 | static float inc_value = 0.1f; 11 | 12 | // Use this for initialization 13 | void Start () { 14 | 15 | } 16 | 17 | // Update is called once per frame 18 | void Update () { 19 | 20 | if(stop_length_counter >= 0f) 21 | { 22 | stop_length_counter -= inc_value; 23 | if(stop_length_counter <= 0f) 24 | { 25 | ResetTimeScale(); 26 | } 27 | } 28 | 29 | } 30 | 31 | void ResetTimeScale() 32 | { 33 | Time.timeScale = 1f; 34 | Time.fixedDeltaTime = 0.02f; 35 | } 36 | 37 | public static void StopTime() 38 | { 39 | Time.timeScale *= TimeFactor; 40 | Time.fixedDeltaTime = 0.02f*TimeFactor; 41 | 42 | stop_length_counter = StopLength; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/Readme.md: -------------------------------------------------------------------------------- 1 | # Ennemi Behaviour 2 | 3 | This class implements a stochastic behaviour. Basically, it works as follows: 4 | 5 | * Define some actions and their probability. These are StochasticBehaviour 6 | * BasicEnnemiSubBehaviour has an array of those actions. When instantiated, it normalized the probabilities. When the `Sample` method is called, it returns a string corresponding to the name of the chosen action, according to probability distribution 7 | * BasicEnnemiSubBehaviour also has min and max distances, that are use by the higher hierarchy to decide which SubBehaviour to use. 8 | * This is implemented in BasicEnnemiBehaviour. When the `SelectAction` method is called, it does what is described above, according to a float corresponding to the distance 9 | * Finally, all of this is held by the BasicEnnemi class which relies on Perso for movement and animation and on a Navigation class and this decision module 10 | 11 | 12 | 13 | ## TODO: 14 | 15 | * Create a custom editor for these behaviors. Would be much easier to use 16 | -------------------------------------------------------------------------------- /DecisionTreeEditor/TestExploDT.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestExploDT : MonoBehaviour { 6 | 7 | public DecisionTree DecisionModule; 8 | 9 | // Use this for initialization 10 | void Start () { 11 | 12 | // Debug.Log(DecisionModule); 13 | // Debug.Log(DecisionModule.nodes); 14 | // Debug.Log(DecisionModule.nodes.Count); 15 | // Debug.Log(DecisionModule.nodes[0]); 16 | // Debug.Log(DecisionModule.nodes[1]); 17 | // Debug.Log(DecisionModule.nodes[2]); 18 | 19 | Debug.Log(DecisionModule.nodes[0]); 20 | Debug.Log(DecisionModule.nodes[0].true_node); 21 | Debug.Log(DecisionModule.nodes[0].false_node); 22 | 23 | // Debug.Log(DecisionModule.genealogy.Keys); 24 | 25 | 26 | GSR s = new GSR(); 27 | s.state = new float []{0.1f}; 28 | string action = DecisionModule.Decide(s); 29 | 30 | Debug.Log(action); 31 | 32 | } 33 | 34 | // Update is called once per frame 35 | void Update () { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /2.5DController/JumpControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class JumpControl : StateMachineBehaviour { 6 | 7 | 8 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 9 | // override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 10 | 11 | // } 12 | 13 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 14 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 15 | Call(animator); 16 | } 17 | 18 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 19 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 20 | animator.ResetTrigger("Land"); 21 | } 22 | 23 | void Call(Animator animator) 24 | { 25 | animator.gameObject.GetComponent().Inform("JumpControl"); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/test_load.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import Loader 3 | import pickle 4 | import mathutils as m 5 | import math 6 | from BasicHuma import Humanoid 7 | 8 | # class Skeleton(): 9 | 10 | # def __init__(self, armature): 11 | 12 | # self.arm = armature 13 | 14 | # self.b0 = armature.pose.bones['b0'] 15 | # self.b1 = armature.pose.bones['b1'] 16 | # self.b2 = armature.pose.bones['b2'] 17 | 18 | # self.bones = [self.b0, self.b1, self.b2] 19 | 20 | # def select(self, nb ): 21 | 22 | # bpy.ops.pose.select_all(action = 'DESELECT') 23 | # self.arm.data.bones[self.bones[nb].name].select = True 24 | 25 | # def create_action(self, name): 26 | 27 | # self.arm.animation_data_create() 28 | # self.arm.animation_data.action = bpy.data.actions.new(name = name) 29 | 30 | # def get_curves(self): 31 | 32 | # anim_d = self.arm.animation_data 33 | # return anim_d.action.fcurves 34 | 35 | print('\n'*100) 36 | path = '/home/mehdi/Blender/Scripts/FcurvesSL/Hook' 37 | 38 | 39 | a = Humanoid(bpy.data.objects['Armature']) 40 | Loader.Load(path ,a, 'MyTest') -------------------------------------------------------------------------------- /DecisionTreeEditor/DTFromCustom.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 0} 12 | m_Name: DTFromCustom 13 | m_EditorClassIdentifier: Assembly-CSharp::DecisionTree 14 | nodes: 15 | - Name: 16 | false_node: 2 17 | true_node: 1 18 | state_value_to_test: 0 19 | test_value: 3 20 | actions: [] 21 | decision_type: 1 22 | - Name: 23 | false_node: 0 24 | true_node: 0 25 | state_value_to_test: 0 26 | test_value: 0 27 | actions: 28 | - decision_id: dash 29 | prob: 0.2 30 | - decision_id: hit 31 | prob: 1 32 | decision_type: 0 33 | - Name: 34 | false_node: 0 35 | true_node: 0 36 | state_value_to_test: 0 37 | test_value: 0 38 | actions: 39 | - decision_id: dash 40 | prob: 0.8 41 | - decision_id: hit 42 | prob: 1 43 | decision_type: 0 44 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWInputs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWInputs : MonoBehaviour { 6 | 7 | public bool UseKeyboard; 8 | public float x; 9 | public float y; 10 | 11 | public bool Jump; 12 | public bool Hit; 13 | public bool CallAxe; 14 | public bool Throw; 15 | public bool ChangeWeapon; 16 | // Use this for initialization 17 | void Start () { 18 | 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | 24 | if(UseKeyboard) 25 | ProcessKB(); 26 | else 27 | ProcessJS(); 28 | 29 | } 30 | 31 | void ProcessKB() 32 | { 33 | 34 | } 35 | 36 | void ProcessJS() 37 | { 38 | x = Input.GetAxis("Horizontal"); 39 | y = Input.GetAxis("Vertical"); 40 | 41 | 42 | Jump = Input.GetButtonDown("AButton") ? true : false; 43 | Hit = Input.GetButtonDown("R1") ? true : false; 44 | CallAxe = Input.GetButtonDown("YButton") ? true : false; 45 | Throw = Input.GetButtonDown("L1") ? true : false; 46 | ChangeWeapon = Input.GetAxis("CroixH") > 0.5f ? true : false; 47 | } 48 | 49 | 50 | public Vector2 GetDirection() 51 | { 52 | return new Vector2(x,y); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Controller/PersoFiller.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class PersoFiller 7 | { 8 | [Header("Attributes")] 9 | public float Speed = 10; 10 | public float RotationSpeed = 2; 11 | public float JumpForce = 350; 12 | public float MaxVelocity = 1000; 13 | public float DashForce = 3; 14 | public float DashTime = 0.5f; 15 | public float AdditionalGravity = 5f; 16 | public float DragFly = 1f; 17 | public float DragGround = 2f; 18 | 19 | [Header("Attributes/Animation")] 20 | public Transform Armature; 21 | public bool UsePivot = true; 22 | public float PivotDelay = 0.2f; 23 | public bool UseLean = true; 24 | public float MaxLeaningAngle = 15; 25 | public float LeanSpeed = 1f; 26 | public bool UseJumpOver = false; 27 | public Vector3 ImpulsionComponents = new Vector3(0, 1f, 0.1f); 28 | public float ImpulsionDuration, ImpulsionStrength, ImpulsionDelay, DetectionDistance; 29 | 30 | 31 | [Header("Character States")] 32 | public List c_states = new List(); 33 | 34 | [Header("Animations States")] 35 | public List states = new List(); 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /BoxingGame/RingResetState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingResetState : StateMachineBehaviour { 6 | 7 | public string Information = "HitEnd"; 8 | public bool OnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | if(OnEnter) 13 | Call(animator); 14 | } 15 | 16 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 17 | // override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 18 | // if(stateInfo.normalizedTime > ExitTime) 19 | // { 20 | // Call(animator); 21 | // } 22 | // } 23 | 24 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 25 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 26 | if(!OnEnter) 27 | Call(animator); 28 | } 29 | 30 | void Call(Animator animator) 31 | { 32 | animator.gameObject.GetComponent().Inform(Information); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /BoxingGame/InputsBoxer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class InputsBoxer : MonoBehaviour { 6 | 7 | public float x, y; 8 | public bool Dash; 9 | public bool Left; 10 | public bool Right; 11 | public bool Upper; 12 | public bool Direct; 13 | public bool Hook; 14 | public bool Dodge; 15 | 16 | // Use this for initialization 17 | void Start () { 18 | 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | 24 | x = Input.GetAxis("Horizontal"); 25 | y = Input.GetAxis("Vertical"); 26 | 27 | Dash = CheckButton("AButton"); 28 | Left = CheckAxis("L2"); 29 | Right = CheckAxis("R2"); 30 | 31 | Upper = CheckButton("YButton"); 32 | Direct = CheckButton("XButton"); 33 | Hook = CheckButton("BButton"); 34 | Dodge = CheckButton("R1"); 35 | 36 | } 37 | 38 | bool CheckAxis(string axis) 39 | { 40 | return Input.GetAxis(axis) > 0.5f ? true : false; 41 | } 42 | 43 | bool CheckButton(string button) 44 | { 45 | if(Input.GetButtonDown(button)) 46 | return true; 47 | else 48 | return false; 49 | } 50 | 51 | public Vector2 GetDirection() 52 | { 53 | return new Vector2(x,y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /AnthemController/DelayedImpulsion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class DelayedImpulsion 7 | { 8 | 9 | public Vector3 Direction; 10 | public float Strengh; 11 | public float Duration; 12 | public bool Active = false; 13 | public float Delay =0f; 14 | float counter = 0.0f; 15 | 16 | public DelayedImpulsion(Vector3 v, float f, float de, float du) 17 | { 18 | Direction = v; 19 | Strengh = f; 20 | Delay = de; 21 | Duration = du; 22 | 23 | if(Delay > 0f) 24 | { 25 | Active = false; 26 | counter = 0.0f; 27 | } 28 | else 29 | { 30 | Active = true; 31 | counter = Duration; 32 | } 33 | } 34 | 35 | public bool Count() 36 | { 37 | if(Active) 38 | { 39 | counter -= Time.deltaTime; 40 | if(counter < 0f) 41 | { 42 | Active = false; 43 | } 44 | } 45 | else 46 | { 47 | if(Delay >0f) 48 | { 49 | Delay -= Time.deltaTime; 50 | if(Delay <= 0f) 51 | { 52 | Active = true; 53 | counter = Duration; 54 | } 55 | } 56 | } 57 | return Active; 58 | } 59 | 60 | public Vector3 Impulse() 61 | { 62 | return Direction*Strengh; 63 | } 64 | 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/DelayedImpulsion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class DelayedImpulsion 7 | { 8 | 9 | public Vector3 Direction; 10 | public float Strengh; 11 | public float Duration; 12 | public bool Active = false; 13 | public float Delay =0f; 14 | float counter = 0.0f; 15 | 16 | public DelayedImpulsion(Vector3 v, float f, float de, float du) 17 | { 18 | Direction = v; 19 | Strengh = f; 20 | Delay = de; 21 | Duration = du; 22 | 23 | if(Delay > 0f) 24 | { 25 | Active = false; 26 | counter = 0.0f; 27 | } 28 | else 29 | { 30 | Active = true; 31 | counter = Duration; 32 | } 33 | } 34 | 35 | public bool Count() 36 | { 37 | if(Active) 38 | { 39 | counter -= Time.deltaTime; 40 | if(counter < 0f) 41 | { 42 | Active = false; 43 | } 44 | } 45 | else 46 | { 47 | if(Delay >0f) 48 | { 49 | Delay -= Time.deltaTime; 50 | if(Delay <= 0f) 51 | { 52 | Active = true; 53 | counter = Duration; 54 | } 55 | } 56 | } 57 | return Active; 58 | } 59 | 60 | public Vector3 Impulse() 61 | { 62 | return Direction*Strengh; 63 | } 64 | 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Controller/Readme.md: -------------------------------------------------------------------------------- 1 | # TPS controller classes and example script 2 | 3 | The controller relies on one main class: `Perso`. This class manages the state machine, the physic and the animations. 4 | 5 | It has a method called `MAJ` that has to be called every frame to update the state machine, ground detection and the animations. 6 | Other methods that are susceptible to be called from outside are: 7 | 8 | * Activate(string name): A method to interact with animator controller and use triggers and so on. 9 | * Move, Jump, Dash 10 | 11 | 12 | ## Other valuable informations 13 | 14 | The class Perso uses one instance of Impulsion to generate accelerations, jumps and so on. The impulsion class 15 | holds informations concerning the time during which the force should be applied, the direction and the magnitude. 16 | 17 | To ease the process of filling the informations relevant to the Perso class (animation states, character states, speed, jump force...) 18 | I implemented a class called PersoFiller which holds these informations and is then used when Perso is instanciated. 19 | 20 | ## Other scripts 21 | 22 | * TPSCam: A camera script for the Camera. Has a method for Aim Focus 23 | * ProjectileBehav: Destroy the projectile and apply force if contact with Rigidbody 24 | 25 | ## TO DO 26 | 27 | Provide a better state machine. 28 | -------------------------------------------------------------------------------- /2.5DController/SendInformationsContinuous.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SendInformationsContinuous : StateMachineBehaviour { 6 | 7 | public string Information; 8 | public bool HasDelay; 9 | public float DelayRatio = 0.1f; 10 | 11 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 12 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 13 | if(!HasDelay) 14 | { 15 | Call(animator); 16 | } 17 | } 18 | 19 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 20 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 21 | if(HasDelay) 22 | { 23 | if(stateInfo.normalizedTime >= DelayRatio) 24 | { 25 | Call(animator); 26 | } 27 | } 28 | else 29 | { 30 | Call(animator); 31 | } 32 | } 33 | 34 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 35 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 36 | } 37 | 38 | void Call(Animator animator) 39 | { 40 | animator.gameObject.GetComponent().Inform(Information); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /ModularController/SendInformationsContinuous.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SendInformationsContinuous : StateMachineBehaviour { 6 | 7 | public string Information; 8 | public bool HasDelay; 9 | public float DelayRatio = 0.1f; 10 | 11 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 12 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 13 | if(!HasDelay) 14 | { 15 | Call(animator); 16 | } 17 | } 18 | 19 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 20 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 21 | if(HasDelay) 22 | { 23 | if(stateInfo.normalizedTime >= DelayRatio) 24 | { 25 | Call(animator); 26 | } 27 | } 28 | else 29 | { 30 | Call(animator); 31 | } 32 | } 33 | 34 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 35 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 36 | } 37 | 38 | void Call(Animator animator) 39 | { 40 | animator.gameObject.GetComponent().Inform(Information); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/BasicEnnemiControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | [RequireComponent(typeof(Rigidbody), typeof(BoxCollider))] 7 | public class BasicEnnemiControl : MonoBehaviour { 8 | 9 | Perso me_perso; 10 | public PersoFiller data; 11 | public BasicEnnemi me; 12 | public GameObject Target; 13 | 14 | public GradientNavigation nav; 15 | 16 | public bool Move; 17 | public bool Act = false; 18 | 19 | // Use this for initialization 20 | void Start () { 21 | 22 | me_perso = new Perso(gameObject,gameObject,data); 23 | me = new BasicEnnemi(me_perso, Target); 24 | 25 | me.SetGradientNavigation(nav); 26 | me.SetBehaviour(GetComponent().Behaviour); 27 | 28 | 29 | } 30 | 31 | // Update is called once per frame 32 | void Update () { 33 | 34 | 35 | if(Move) 36 | me.GoToEnnemi(); 37 | 38 | if(Act) 39 | { 40 | Act = false; 41 | string s = me.TestAction(); 42 | Debug.Log(s); 43 | } 44 | 45 | 46 | 47 | 48 | } 49 | 50 | 51 | // void OnDrawGizmos() 52 | // { 53 | // Gizmos.color = Color.green; 54 | 55 | // Vector3 [] liste = nav.DebugVec(); 56 | // foreach (Vector3 v in liste) 57 | // { 58 | // Gizmos.DrawSphere(transform.position - v, 0.5f); 59 | // } 60 | // } 61 | } 62 | -------------------------------------------------------------------------------- /2.5DController/SendInformations.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SendInformations : StateMachineBehaviour { 6 | 7 | public string Information; 8 | public bool HasDelay; 9 | public float DelayRatio = 0.1f; 10 | 11 | bool ready = true; 12 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 13 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | if(!HasDelay) 15 | { 16 | Call(animator); 17 | } 18 | } 19 | 20 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 21 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | if(HasDelay && ready) 23 | { 24 | if(stateInfo.normalizedTime >= DelayRatio) 25 | { 26 | Call(animator); 27 | ready = false; 28 | } 29 | } 30 | } 31 | 32 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 33 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 34 | ready = true; 35 | } 36 | 37 | void Call(Animator animator) 38 | { 39 | animator.gameObject.GetComponent().Inform(Information); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Classes/Detector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class Detector 7 | { 8 | 9 | [HideInInspector] 10 | public GameObject Holder; 11 | [HideInInspector] 12 | public GameObject Ennemi; 13 | public float Distance = 10; 14 | public float MaxAngle = 180; 15 | public float Angle = 0; 16 | 17 | [HideInInspector] 18 | public LayerMask Mask; 19 | [HideInInspector] 20 | public float Increment = 11; 21 | [HideInInspector] 22 | public bool HasEnnemi = false; 23 | 24 | public Detector(GameObject G, LayerMask l) 25 | { 26 | Holder = G; 27 | Mask = l ; 28 | } 29 | 30 | public bool Observe() 31 | { 32 | Vector3 dir = Quaternion.AngleAxis(Angle, Vector3.up)*Holder.transform.forward; 33 | Ray ray = new Ray(Holder.transform.position,dir); 34 | 35 | // Debug.DrawRay(ray.origin, ray.direction*Distance, Color.red, 1.0f); 36 | RaycastHit hit; 37 | 38 | bool b = false; 39 | 40 | if(Physics.Raycast(ray, out hit, Distance, Mask)) 41 | { 42 | Ennemi = hit.transform.gameObject; 43 | b = true; 44 | Debug.Log("Found one"); 45 | } 46 | 47 | Angle = (Angle + Increment > MaxAngle) ? -MaxAngle + (Angle+Increment)%MaxAngle : Angle + Increment; 48 | return b; 49 | } 50 | 51 | public GameObject GetEnnemi() 52 | { 53 | return Ennemi; 54 | } 55 | 56 | 57 | 58 | 59 | 60 | 61 | } -------------------------------------------------------------------------------- /ModularController/SendInformations.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SendInformations : StateMachineBehaviour { 6 | 7 | public string Information; 8 | public bool HasDelay; 9 | public float DelayRatio = 0.1f; 10 | 11 | bool ready = true; 12 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 13 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | if(!HasDelay) 15 | { 16 | Call(animator); 17 | } 18 | } 19 | 20 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 21 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | if(HasDelay && ready) 23 | { 24 | if(stateInfo.normalizedTime >= DelayRatio) 25 | { 26 | Call(animator); 27 | ready = false; 28 | } 29 | } 30 | } 31 | 32 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 33 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 34 | ready = true; 35 | } 36 | 37 | void Call(Animator animator) 38 | { 39 | animator.gameObject.GetComponent().Inform(Information); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /ModularController/ModularController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ModularController : MonoBehaviour { 6 | 7 | FightModule fight; 8 | Inputs2B inputs; 9 | MoveModule move; 10 | 11 | // Use this for initialization 12 | void Start () { 13 | 14 | inputs = GetComponent(); 15 | fight = GetComponent(); 16 | move = GetComponent(); 17 | } 18 | 19 | // Update is called once per frame 20 | void Update () { 21 | 22 | bool jump = inputs.Jump; 23 | bool dash = inputs.Dash; 24 | bool hit = inputs.Hit; 25 | bool shoot = inputs.Shoot; 26 | bool heavy_hit = inputs.HeavyHit; 27 | 28 | Vector2 direction = inputs.GetDirection(); 29 | 30 | move.PlayerMove(direction); 31 | fight.Hit(hit, heavy_hit); 32 | if(dash) 33 | move.Dash(); 34 | 35 | if(shoot) 36 | fight.Shoot(); 37 | } 38 | 39 | public void Inform(string info) 40 | { 41 | if(info == "Dash") 42 | { 43 | move.DashMove(); 44 | } 45 | if(info == "Shoot") 46 | { 47 | fight.ShootAction(); 48 | } 49 | } 50 | 51 | public void Switch(string info, bool state) 52 | { 53 | if(info == "LF" || 54 | info == "RH" || 55 | info == "RF" || 56 | info == "LH" ) 57 | { 58 | fight.Switch(info, state); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /BoxingGame/RingDodgeInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingDodgeInfo : StateMachineBehaviour { 6 | 7 | public string Information = "Dodge"; 8 | public string [] HitboxName; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Switch(animator, true); 13 | } 14 | 15 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 16 | // override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 17 | // if(stateInfo.normalizedTime > ExitTime) 18 | // { 19 | // Call(animator); 20 | // } 21 | // } 22 | 23 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 24 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 25 | animator.SetBool("Left", false); 26 | animator.SetBool("Right", false); 27 | Switch(animator, false); 28 | } 29 | 30 | void Switch(Animator animator, bool state) 31 | { 32 | foreach(string s in HitboxName) 33 | { 34 | animator.gameObject.GetComponent().SwitchHitbox(s, state, true); 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseInputs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseInputs : MonoBehaviour { 6 | 7 | public bool UseKeyboard; 8 | public float x; 9 | public float y; 10 | 11 | public bool Jump; 12 | public bool Hit; 13 | public bool CallAxe; 14 | public bool Throw; 15 | public bool ChangeWeapon; 16 | public bool HighSpeed; 17 | public bool HoldThrow; 18 | // Use this for initialization 19 | void Start () { 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update () { 25 | 26 | if(UseKeyboard) 27 | ProcessKB(); 28 | else 29 | ProcessJS(); 30 | 31 | } 32 | 33 | void ProcessKB() 34 | { 35 | CallAxe = Input.GetMouseButtonDown(1) ? true : false; 36 | Throw = Input.GetMouseButtonDown(0) ? true : false; 37 | } 38 | 39 | void ProcessJS() 40 | { 41 | x = Input.GetAxis("Horizontal"); 42 | y = Input.GetAxis("Vertical"); 43 | 44 | 45 | Jump = Input.GetButtonDown("AButton") ? true : false; 46 | Hit = Input.GetButtonDown("R1") ? true : false; 47 | CallAxe = Input.GetButtonDown("YButton") ? true : false; 48 | Throw = Input.GetButtonDown("L1") ? true : false; 49 | ChangeWeapon = Input.GetAxis("CroixH") > 0.5f ? true : false; 50 | HoldThrow = Input.GetAxis("R2") > 0.5f ? true: false; 51 | } 52 | 53 | 54 | public Vector2 GetDirection() 55 | { 56 | return new Vector2(x,y); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/FightingStateBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class FightingStateBehaviour : StateMachineBehaviour { 6 | 7 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 8 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 9 | animator.SetBool("ExitBool", true); 10 | } 11 | 12 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 13 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | // 15 | //} 16 | 17 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 18 | //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 19 | // 20 | //} 21 | 22 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 23 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 24 | // 25 | //} 26 | 27 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 28 | //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 29 | // 30 | //} 31 | } 32 | -------------------------------------------------------------------------------- /2.5DController/ModularController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ModularController : MonoBehaviour { 6 | 7 | FightModule fight; 8 | Inputs2B inputs; 9 | MoveModule move; 10 | 11 | // Use this for initialization 12 | void Start () { 13 | 14 | inputs = GetComponent(); 15 | fight = GetComponent(); 16 | move = GetComponent(); 17 | } 18 | 19 | // Update is called once per frame 20 | void Update () { 21 | 22 | bool jump = inputs.Jump; 23 | bool dash = inputs.Dash; 24 | bool hit = inputs.Hit; 25 | bool shoot = inputs.Shoot; 26 | bool heavy_hit = inputs.HeavyHit; 27 | 28 | Vector2 direction = inputs.GetDirection(); 29 | 30 | move.PlayerMove(direction, jump); 31 | fight.Hit(hit, heavy_hit); 32 | 33 | if(dash) 34 | move.Dash(); 35 | 36 | if(shoot) 37 | fight.Shoot(); 38 | } 39 | 40 | public void Inform(string info) 41 | { 42 | if(info == "Dash") 43 | { 44 | move.DashMove(); 45 | } 46 | if(info == "Shoot") 47 | { 48 | fight.ShootAction(); 49 | } 50 | if(info == "JumpControl") 51 | { 52 | move.JumpControl(); 53 | } 54 | } 55 | 56 | public void Switch(string info, bool state) 57 | { 58 | if(info == "LF" || 59 | info == "RH" || 60 | info == "RF" || 61 | info == "LH" ) 62 | { 63 | fight.Switch(info, state); 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /AnthemController/PersoFillerShooter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class PersoFillerShooter 7 | { 8 | [Header("Physics Attributes")] 9 | public float Speed = 200; 10 | public float RotationSpeed = 10; 11 | public float JumpForce = 5; 12 | public float MaxVelocity = 1000; 13 | public float DashForce = 3; 14 | public float DashTime = 0.5f; 15 | public float AdditionalGravity = 1f; 16 | public float DragFly = 1f; 17 | public float DragGround = 1f; 18 | 19 | [Header("Speficic Attributes")] 20 | public bool UseStep = false; 21 | public float AngleBeforeStep = 30; 22 | public float StepSpeed = 5; 23 | public float AngleTarget = 45; 24 | public float MinAngleStep = 5f; 25 | 26 | 27 | [Header("Fly Attributes")] 28 | public bool UseFlight = false; 29 | public float LandingSpeed = 5f; 30 | public float MinSpeedLandingRatio = 3; 31 | 32 | [Header("SuperFly Attributes")] 33 | public bool UseSuperFly = false; 34 | public float StraightSpeed = 5f; 35 | public float SuperFlyRotationSpeed = 3f; 36 | public float VerticalRatio = 0.5f; 37 | 38 | 39 | [Header("Special Effects")] 40 | public bool UseSpecialEffects = true; 41 | public List FXHolder = new List(); 42 | 43 | 44 | public List AnimationStates = new List(); 45 | public List CharacterState = new List(); 46 | 47 | 48 | } -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/BasicEnnemi.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BasicEnnemi 6 | { 7 | 8 | public Perso me; 9 | public GameObject Target; 10 | 11 | public GradientNavigation nav; 12 | public BasicEnnemiBehaviour behav; 13 | 14 | 15 | public BasicEnnemi(Perso m, GameObject t) 16 | { 17 | me = m; 18 | Target = t; 19 | } 20 | 21 | public BasicEnnemi(Perso m, GameObject t, GradientNavigation n) 22 | { 23 | me = m; 24 | Target = t; 25 | n = nav; 26 | } 27 | 28 | public BasicEnnemi(Perso m, GameObject t, GradientNavigation n, BasicEnnemiBehaviour b) 29 | { 30 | me = m; 31 | Target = t; 32 | n = nav; 33 | behav = b; 34 | } 35 | 36 | public void SetGradientNavigation(GradientNavigation n) 37 | { 38 | nav = n; 39 | } 40 | 41 | public void SetBehaviour(BasicEnnemiBehaviour b) 42 | { 43 | behav = b; 44 | } 45 | 46 | public void GoToEnnemi() 47 | { 48 | Vector3 v = Target.transform.position - me.transform.position; 49 | v.y = 0; 50 | if(v.magnitude > 5.0f) 51 | { 52 | if(nav != null) 53 | { 54 | v = nav.Navigate(me.transform, v); // Use gradient navigation if possible 55 | } 56 | me.Move(v); 57 | 58 | } 59 | 60 | } 61 | 62 | public string TestAction() 63 | { 64 | Vector3 v = Target.transform.position - me.transform.position; 65 | string action = behav.SelectAction(v.magnitude); 66 | 67 | return action; 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /Classes/Gun.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class Gun 7 | { 8 | public Transform transform; 9 | public LayerMask Mask; 10 | public float Range = 15; 11 | 12 | public LineRenderer line; 13 | public ParticleSystem effect; 14 | 15 | public Gun(Transform t, LayerMask l, LineRenderer ll) 16 | { 17 | transform = t; 18 | Mask = l; 19 | line = ll; 20 | line.enabled = false; 21 | 22 | 23 | } 24 | 25 | public void Shoot() 26 | { 27 | Ray ray = new Ray (transform.position, transform.forward); 28 | RaycastHit hit; 29 | 30 | line.enabled = true; 31 | ParticleSystem e = Object.Instantiate(effect, transform.position + 0.1f*transform.forward, Quaternion.identity) as ParticleSystem; 32 | Object.Destroy(e,0.3f); 33 | 34 | if (Physics.Raycast(ray, out hit, Range, Mask)) 35 | { 36 | GameObject go = hit.transform.gameObject; 37 | go.GetComponent().Touched(); 38 | line.SetPosition(0, transform.position + 0.1f*transform.forward); 39 | line.SetPosition(1, go.transform.position); 40 | ParticleSystem ee = Object.Instantiate(effect, hit.point, Quaternion.identity) as ParticleSystem; 41 | Object.Destroy(ee,0.3f); 42 | } 43 | else 44 | { 45 | line.SetPosition(0, transform.position + 0.1f*transform.forward); 46 | line.SetPosition(1, transform.position + Range*transform.forward); 47 | } 48 | 49 | 50 | 51 | } 52 | 53 | public void StopEffects() 54 | { 55 | line.enabled = false; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /ModularController/ParticlesBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ParticlesBehaviour : MonoBehaviour { 6 | 7 | public Transform Shooter; 8 | public float Speed; 9 | public float Lifetime = 3f; 10 | 11 | public GameObject ExplosionOnImpact; 12 | public GameObject OnStartObject; 13 | 14 | Vector3 Direction = Vector3.zero; 15 | Quaternion Rotation = Quaternion.identity; 16 | 17 | // Use this for initialization 18 | void Start () { 19 | 20 | if(OnStartObject != null) 21 | { 22 | Creation(OnStartObject); 23 | } 24 | Destroy(gameObject, Lifetime); 25 | } 26 | 27 | // Update is called once per frame 28 | void Update () { 29 | transform.position += Direction*Speed*Time.deltaTime; 30 | } 31 | 32 | void OnTriggerEnter(Collider other) 33 | { 34 | if(ExplosionOnImpact != null) 35 | { 36 | Creation(ExplosionOnImpact); 37 | // ImpactBox impact = other.gameObject.GetComponent(); 38 | HitImpact impact = other.gameObject.GetComponent(); 39 | if(impact != null) 40 | { 41 | impact.ParticleImpact(); 42 | } 43 | Destroy(gameObject); 44 | } 45 | } 46 | 47 | public void SetShooter(Transform t) 48 | { 49 | Shooter = t; 50 | Direction = Shooter.forward; 51 | Rotation = Shooter.rotation; 52 | } 53 | 54 | void Creation(GameObject target) 55 | { 56 | GameObject p = Instantiate(target, transform.position, Rotation*target.transform.rotation) as GameObject; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ReCompileCubes/TestRotation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestRotation : MonoBehaviour { 6 | 7 | public Mesh mesh; 8 | public Material material; 9 | public Collider collider; 10 | 11 | public float Finesse; 12 | 13 | Vector3 Increment; 14 | 15 | 16 | // Use this for initialization 17 | void Start () { 18 | 19 | Increment = collider.bounds.size/Finesse; 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update () { 25 | 26 | List matrix = new List(); 27 | 28 | Vector3 sizes = collider.bounds.size; 29 | for(float i = -(sizes.x-Finesse)/2 ; i< (sizes.x - Finesse)/2; i+= Finesse) 30 | { 31 | for(float j = -(sizes.y-Finesse)/2; j< (sizes.y - Finesse)/2; j+= Finesse) 32 | { 33 | for(float h = -(sizes.z-Finesse)/2; h< (sizes.z - Finesse)/2; h+= Finesse) 34 | { 35 | Vector3 pos = collider.bounds.center + transform.right*h+ transform.forward*i + transform.up*j; 36 | if(collider.bounds.Contains(pos)) 37 | { 38 | matrix.Add(Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one*0.7f*Finesse)); 39 | } 40 | 41 | } 42 | } 43 | } 44 | 45 | Debug.DrawRay(transform.position, transform.forward*5, Color.red, 1); 46 | Debug.DrawRay(transform.position, transform.right*5, Color.green, 1); 47 | Debug.DrawRay(transform.position, transform.up*5, Color.blue, 1); 48 | 49 | Graphics.DrawMeshInstanced(mesh, 0, material, matrix); 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/SamuraiController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SamuraiController : MonoBehaviour { 6 | 7 | public bool DEBUG = false; 8 | 9 | [Space(50)] 10 | public GameObject Ennemi; 11 | public SamuraiFiller Filler; 12 | PersoSamurai me; 13 | 14 | 15 | 16 | // Use this for initialization 17 | void Start () { 18 | me = new PersoSamurai(gameObject, Filler, Camera.main); 19 | me.SetEnnemi(Ennemi); 20 | } 21 | 22 | // Update is called once per frame 23 | void Update () { 24 | 25 | me.MAJ(); 26 | float x = Input.GetAxis("Horizontal"); 27 | float y = Input.GetAxis("Vertical"); 28 | 29 | me.PlayerMove(x,y); 30 | 31 | // if(Input.GetButtonDown("XButton")) 32 | if(Input.GetKeyDown(KeyCode.E)) 33 | { 34 | me.HitActivation("Hit"); 35 | } 36 | // if(Input.GetButtonDown("YButton")) 37 | if(Input.GetKeyDown(KeyCode.R)) 38 | { 39 | me.HitActivation("HitSV"); 40 | } 41 | // if(Input.GetButtonDown("BButton")) 42 | if(Input.GetKeyDown(KeyCode.T)) 43 | { 44 | me.HitActivation("HitSH"); 45 | } 46 | // } 47 | // if(Input.GetButtonDown("BButton")) 48 | // me.Dodge(x,y); 49 | 50 | // if(Input.GetButtonDown("YButton")) 51 | // me.ActivateDash() ; 52 | 53 | // DashEffect(); 54 | DebugFunc(); 55 | 56 | } 57 | 58 | void DebugFunc() 59 | { 60 | if(DEBUG) 61 | { 62 | DEBUG = !DEBUG; 63 | me = new PersoSamurai(gameObject, Filler, Camera.main); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Classes/EnnemiBehaviour/BasicEnnemiSubBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | [System.Serializable] 7 | public class BasicEnnemiSubBehaviour 8 | { 9 | public string Name = "Type"; 10 | public float DistanceMin; 11 | public float DistanceMax; 12 | public StochasticBehaviour [] Actions; 13 | 14 | 15 | bool FirstTime= true; 16 | float SumProbas = 0f; 17 | float [] limits; 18 | 19 | public BasicEnnemiSubBehaviour() 20 | { 21 | 22 | // NormalizeAll(); 23 | } 24 | 25 | public void NormalizeAll() 26 | { 27 | foreach (StochasticBehaviour sb in Actions) 28 | { 29 | SumProbas += sb.Probability; 30 | } 31 | 32 | foreach (StochasticBehaviour sb in Actions) 33 | { 34 | sb.Probability /= SumProbas; 35 | } 36 | 37 | limits = new float [Actions.Length+1]; 38 | 39 | for(int i = 1; i limits[i-1] && f < limits[i]) 69 | selection = i-1; 70 | } 71 | 72 | return Actions[selection].Action; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWCamIsom.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWCamIsom : MonoBehaviour { 6 | 7 | public Transform Target; 8 | public float DampSpeed = 2; 9 | public float LookFocusSpeed = 5; 10 | public float RotationSpeed = 5; 11 | public Vector2 LimX; 12 | 13 | Vector3 Offset; 14 | Vector3 velocity= Vector3.zero; 15 | 16 | float angleY = 0; 17 | float angleX = 0; 18 | Vector3 LookTarget; 19 | Vector3 TargetPos; 20 | 21 | // Use this for initialization 22 | void Start () { 23 | 24 | Offset = transform.position - Target.transform.position; 25 | LookTarget = Target.position; 26 | TargetPos = transform.position; 27 | 28 | } 29 | 30 | // Update is called once per frame 31 | void Update () { 32 | 33 | transform.LookAt(Target); 34 | float ix = Input.GetAxis("VerCam")*0f; 35 | float iy = Input.GetAxis("HorCam"); 36 | 37 | 38 | Vector3 rotated_offset = Rotate(ix*RotationSpeed, iy*RotationSpeed)*Offset; 39 | TargetPos = Target.position + rotated_offset; 40 | transform.LookAt(Target.position); 41 | 42 | } 43 | 44 | void FixedUpdate() 45 | { 46 | AdaptPosition(); 47 | } 48 | void AdaptPosition() 49 | { 50 | transform.position = Vector3.SmoothDamp(transform.position,TargetPos, ref velocity, DampSpeed*Time.deltaTime); 51 | } 52 | 53 | Quaternion Rotate(float x, float y) 54 | { 55 | angleX += x; 56 | angleY += y; 57 | 58 | angleX = Mathf.Clamp(angleX,LimX.x, LimX.y); 59 | Quaternion r = Quaternion.AngleAxis(angleX, transform.right)*Quaternion.AngleAxis(angleY,Vector3.up); 60 | return r; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWCam.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWCam : MonoBehaviour { 6 | 7 | public Transform Target; 8 | public float DampSpeed = 2; 9 | public float LookFocusSpeed = 5; 10 | public float RotationSpeed = 5; 11 | public Vector2 LimX; 12 | 13 | Vector3 Offset; 14 | Vector3 velocity= Vector3.zero; 15 | 16 | float angleY = 0; 17 | float angleX = 0; 18 | Vector3 LookTarget; 19 | Vector3 TargetPos; 20 | 21 | // Use this for initialization 22 | void Start () { 23 | 24 | Offset = transform.position - Target.transform.position; 25 | LookTarget = Target.position; 26 | TargetPos = transform.position; 27 | 28 | } 29 | 30 | // Update is called once per frame 31 | void Update () { 32 | 33 | transform.LookAt(Target); 34 | float ix = Input.GetAxis("VerCam"); 35 | float iy = Input.GetAxis("HorCam"); 36 | 37 | 38 | Vector3 rotated_offset = Rotate(ix*RotationSpeed, iy*RotationSpeed)*Offset; 39 | TargetPos = Target.position + rotated_offset; 40 | transform.LookAt(Target.position); 41 | 42 | } 43 | 44 | void FixedUpdate() 45 | { 46 | AdaptPosition(); 47 | } 48 | void AdaptPosition() 49 | { 50 | transform.position = Vector3.SmoothDamp(transform.position,TargetPos, ref velocity, DampSpeed*Time.deltaTime); 51 | } 52 | 53 | Quaternion Rotate(float x, float y) 54 | { 55 | angleX += x; 56 | angleY += y; 57 | 58 | angleX = Mathf.Clamp(angleX,LimX.x, LimX.y); 59 | Quaternion r = Quaternion.AngleAxis(angleX, transform.right)*Quaternion.AngleAxis(angleY,Vector3.up); 60 | return r; 61 | } 62 | } -------------------------------------------------------------------------------- /BoxingGame/CamBoxer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class CamBoxer : MonoBehaviour { 6 | 7 | public Transform Target; 8 | public float DampSpeed = 2; 9 | public float LookFocusSpeed = 5; 10 | public float RotationSpeed = 5; 11 | public Vector2 LimX; 12 | 13 | Vector3 Offset; 14 | Vector3 velocity= Vector3.zero; 15 | 16 | float angleY = 0; 17 | float angleX = 0; 18 | Vector3 LookTarget; 19 | Vector3 TargetPos; 20 | 21 | // Use this for initialization 22 | void Start () { 23 | 24 | Offset = transform.position - Target.transform.position; 25 | LookTarget = Target.position; 26 | TargetPos = transform.position; 27 | 28 | } 29 | 30 | // Update is called once per frame 31 | void Update () { 32 | 33 | transform.LookAt(Target); 34 | float ix = Input.GetAxis("VerCam"); 35 | float iy = Input.GetAxis("HorCam"); 36 | 37 | 38 | Vector3 rotated_offset = Rotate(ix*RotationSpeed, iy*RotationSpeed)*Offset; 39 | TargetPos = Target.position + rotated_offset; 40 | transform.LookAt(Target.position); 41 | 42 | } 43 | 44 | void FixedUpdate() 45 | { 46 | AdaptPosition(); 47 | } 48 | void AdaptPosition() 49 | { 50 | transform.position = Vector3.SmoothDamp(transform.position,TargetPos, ref velocity, DampSpeed*Time.deltaTime); 51 | } 52 | 53 | Quaternion Rotate(float x, float y) 54 | { 55 | angleX += x; 56 | angleY += y; 57 | 58 | angleX = Mathf.Clamp(angleX,LimX.x, LimX.y); 59 | Quaternion r = Quaternion.AngleAxis(angleX, transform.right)*Quaternion.AngleAxis(angleY,Vector3.up); 60 | return r; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /God of War- ReMehd/InformModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class InformModular : StateMachineBehaviour { 6 | 7 | public string Information = "Message to transmit"; 8 | public bool EnterExit = true; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Inform(animator, true); 13 | } 14 | 15 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 16 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 17 | // 18 | //} 19 | 20 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 21 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | Inform(animator, false); 23 | } 24 | 25 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 26 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 27 | // 28 | //} 29 | 30 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 31 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | 33 | // } 34 | 35 | 36 | void Inform(Animator animator, bool state) 37 | { 38 | animator.gameObject.GetComponent().Inform(Information, state); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseInformModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseInformModular : StateMachineBehaviour { 6 | 7 | public string Information = "Message to transmit"; 8 | public bool EnterExit = true; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Inform(animator, true); 13 | } 14 | 15 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 16 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 17 | // 18 | //} 19 | 20 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 21 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | Inform(animator, false); 23 | } 24 | 25 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 26 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 27 | // 28 | //} 29 | 30 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 31 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | 33 | // } 34 | 35 | 36 | void Inform(Animator animator, bool state) 37 | { 38 | animator.gameObject.GetComponent().Inform(Information, state); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /God of War- ReMehd/HitInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class HitInfo : StateMachineBehaviour { 6 | 7 | public HitData hit_data; 8 | public bool ResetHitOnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Call(animator, true); 13 | if(ResetHitOnEnter) 14 | animator.SetBool("Hit", false); 15 | } 16 | 17 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 18 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 19 | // 20 | //} 21 | 22 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 23 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 24 | Call(animator, false); 25 | } 26 | 27 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 28 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 29 | // 30 | //} 31 | 32 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 33 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 34 | 35 | // } 36 | 37 | 38 | void Call(Animator animator, bool state) 39 | { 40 | animator.gameObject.GetComponent().HitInform(hit_data, state); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseHitInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseHitInfo : StateMachineBehaviour { 6 | 7 | public BaseHitData hit_data; 8 | public bool ResetHitOnEnter; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Call(animator, true); 13 | if(ResetHitOnEnter) 14 | animator.SetBool("Hit", false); 15 | } 16 | 17 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 18 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 19 | // 20 | //} 21 | 22 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 23 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 24 | Call(animator, false); 25 | } 26 | 27 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 28 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 29 | // 30 | //} 31 | 32 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 33 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 34 | 35 | // } 36 | 37 | 38 | void Call(Animator animator, bool state) 39 | { 40 | animator.gameObject.GetComponent().HitInform(hit_data, state); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /GhostOfTsushimaController/ImpulsionHolder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class ImpulsionHolder 7 | { 8 | 9 | public DelayedImpulsion impulsion; 10 | public string Correspondance = "Name"; 11 | 12 | public List Correspondances = new List(); 13 | string current_name = ""; 14 | 15 | int max_enumerator = 0; 16 | int enumerator = 0; 17 | bool ready = false; 18 | 19 | bool active = false; 20 | 21 | public ImpulsionHolder() 22 | { 23 | 24 | } 25 | 26 | void Init() 27 | { 28 | ready = true; 29 | current_name = Correspondances[0]; 30 | } 31 | 32 | public bool Analyze(string c) 33 | { 34 | if(!ready) 35 | Init(); 36 | 37 | bool result = false; 38 | if(Correspondances.Contains(c)) 39 | { 40 | result = SwitchOn(c); 41 | Debug.Log(c); 42 | } 43 | else 44 | { 45 | SwitchOff(); 46 | } 47 | 48 | return result; 49 | } 50 | 51 | bool SwitchOn(string s) 52 | { 53 | if(!active) 54 | { 55 | active = true; 56 | return true; 57 | } 58 | else 59 | { 60 | if(current_name == s) 61 | return false; 62 | else 63 | { 64 | current_name = s; 65 | return true; 66 | } 67 | } 68 | } 69 | 70 | void SwitchOff() 71 | { 72 | active = false; 73 | } 74 | 75 | public DelayedImpulsion GetClone(Transform t) 76 | { 77 | Vector3 v = t.forward*impulsion.Direction.z + t.right*impulsion.Direction.x + t.up*impulsion.Direction.y; 78 | DelayedImpulsion i = new DelayedImpulsion(v.normalized,impulsion.Strengh,impulsion.Delay,impulsion.Duration); 79 | return i ; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /God of War- ReMehd/StatesReset.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class StatesReset : StateMachineBehaviour { 6 | 7 | public string [] TriggersToReset; 8 | public string [] BoolsToReset; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Reset(animator); 13 | } 14 | 15 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 16 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 17 | // 18 | //} 19 | 20 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 21 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | // Inform(animator, false); 23 | } 24 | 25 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 26 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 27 | // 28 | //} 29 | 30 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 31 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | 33 | // } 34 | 35 | 36 | void Reset(Animator animator) 37 | { 38 | foreach(string s in TriggersToReset) 39 | { 40 | animator.ResetTrigger(s); 41 | } 42 | foreach(string s in BoolsToReset) 43 | { 44 | animator.SetBool(s, false); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseStatesReset.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseStatesReset : StateMachineBehaviour { 6 | 7 | public string [] TriggersToReset; 8 | public string [] BoolsToReset; 9 | 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 12 | Reset(animator); 13 | } 14 | 15 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 16 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 17 | // 18 | //} 19 | 20 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 21 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 22 | // Inform(animator, false); 23 | } 24 | 25 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 26 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 27 | // 28 | //} 29 | 30 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 31 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | 33 | // } 34 | 35 | 36 | void Reset(Animator animator) 37 | { 38 | foreach(string s in TriggersToReset) 39 | { 40 | animator.ResetTrigger(s); 41 | } 42 | foreach(string s in BoolsToReset) 43 | { 44 | animator.SetBool(s, false); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /BoxingGame/RingContinuousInfos.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingContinuousInfos : StateMachineBehaviour { 6 | 7 | public string Information; 8 | public bool HasDelay; 9 | public float DelayRatio = 0.1f; 10 | public bool HasExitTime; 11 | public float ExitTime; 12 | 13 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 14 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 15 | if(!HasDelay) 16 | { 17 | Call(animator); 18 | } 19 | } 20 | 21 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 22 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 23 | if(HasDelay) 24 | { 25 | if(stateInfo.normalizedTime >= DelayRatio) 26 | { 27 | if(HasExitTime) 28 | { 29 | if(stateInfo.normalizedTime <= ExitTime) 30 | Call(animator); 31 | } 32 | else 33 | { 34 | Call(animator); 35 | } 36 | 37 | } 38 | } 39 | else 40 | { 41 | if(HasExitTime) 42 | { 43 | if(stateInfo.normalizedTime <= ExitTime) 44 | Call(animator); 45 | } 46 | else 47 | { 48 | Call(animator); 49 | } 50 | 51 | } 52 | } 53 | 54 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 55 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 56 | } 57 | 58 | void Call(Animator animator) 59 | { 60 | animator.gameObject.GetComponent().Inform(Information); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /2.5DController/Inputs2B.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Inputs2B : MonoBehaviour { 6 | 7 | public bool UseKeyboard; 8 | public float x; 9 | public float y; 10 | 11 | public bool Jump; 12 | public bool Dash; 13 | public bool Hit; 14 | public bool Shoot; 15 | public bool HeavyHit; 16 | 17 | 18 | // Use this for initialization 19 | void Start () { 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update () { 25 | 26 | ProcessInput(); 27 | ProcessButton(); 28 | 29 | } 30 | 31 | public Vector2 GetDirection() 32 | { 33 | return new Vector2(x,y); 34 | } 35 | 36 | void ProcessInput() 37 | { 38 | if(UseKeyboard) 39 | { 40 | x = Input.GetAxis("kHorizontal"); 41 | y = Input.GetAxis("kVertical"); 42 | 43 | if(Input.GetKeyDown(KeyCode.K)) 44 | { 45 | x = 1f; 46 | } 47 | else if (Input.GetKeyDown(KeyCode.H)) 48 | { 49 | x = -1f; 50 | } 51 | else 52 | { 53 | x = 0f; 54 | } 55 | } 56 | else 57 | { 58 | x = Input.GetAxis("Horizontal"); 59 | y = Input.GetAxis("Vertical"); 60 | } 61 | } 62 | 63 | void ProcessButton() 64 | { 65 | if(UseKeyboard) 66 | { 67 | if(Input.GetKeyDown(KeyCode.Space)) 68 | Jump = true; 69 | else 70 | Jump = false; 71 | } 72 | else 73 | { 74 | Jump = Check("AButton"); 75 | Dash = Check("BButton"); 76 | Hit = Check("XButton"); 77 | Shoot = Check("R1"); 78 | HeavyHit = Check("YButton"); 79 | } 80 | } 81 | 82 | bool Check(string input_name) 83 | { 84 | if(Input.GetButtonDown(input_name)) 85 | return true; 86 | else 87 | return false; 88 | } 89 | } 90 | 91 | -------------------------------------------------------------------------------- /BoxingGame/RingHitInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingHitInfo : StateMachineBehaviour { 6 | 7 | public string Information = "HitEnd"; 8 | public float ExitTime = 0.9f; 9 | public string HitboxName; 10 | public bool AddForceOnEnter = false; 11 | 12 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 13 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | Switch(animator, true); 15 | if(AddForceOnEnter) 16 | { 17 | CallImpulsion(animator); 18 | } 19 | } 20 | 21 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 22 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 23 | if(stateInfo.normalizedTime > ExitTime) 24 | { 25 | Call(animator); 26 | } 27 | } 28 | 29 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 30 | override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 31 | animator.SetBool("Left", false); 32 | animator.SetBool("Right", false); 33 | Switch(animator, false); 34 | } 35 | 36 | void Call(Animator animator) 37 | { 38 | animator.gameObject.GetComponent().Inform(Information); 39 | } 40 | 41 | void CallImpulsion(Animator animator) 42 | { 43 | animator.gameObject.GetComponent().Inform("Impulsion"); 44 | } 45 | 46 | void Switch(Animator animator, bool state) 47 | { 48 | animator.gameObject.GetComponent().SwitchHitbox(HitboxName, state); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /QuickAnimation/Readme.md: -------------------------------------------------------------------------------- 1 | # Update 26/08/18 2 | 3 | * Minor fixes in QuickAnimation.py 4 | * Created a script to automatically force a bone to follow a target bone(position and rotation) for one or all animations. Useful for adding a weapon and having it follow the hand, the back or whichever other bone during throughout all animations. Of course, result is still tweakable afterwards. 5 | 6 | ## TODO 7 | * Add possibility to offset the bone (both vector or rotation) 8 | 9 | 10 | 11 | # Quick animation scripts 12 | 13 | 1. Use UnityArmature.py to generate an armature consistent with futher steps 14 | 1. Use FcurvesOperator.py to save or load animations. 15 | 1. If you add new bones to the structure: make sure their name starts with `other_` and be aware that they will not be recorded in the animation 16 | 17 | 18 | # New version ! 19 | Several improvements have been made: 20 | * No need to insert keyframes for all the bones 21 | * No restriction on names. Whichever name you used to record the animation will be used as reference for loading it. 22 | * Has a small tentative to conserve proportions via a ratio 23 | 24 | 25 | Example at : https://youtu.be/b1CiLcGc3Rw 26 | 27 | 28 | # Newer version ! 29 | Most important improvement: Rigify support ! There is now no limit as to the rig you use. Tested on BasicHuman, BasicQuadruped. Some things that could be improved: 30 | 31 | * No more support for the ratio. Given that the structure has changed, the scripts now finds bones by name, and given the number of bones in rigify, I did not go over them all. One idea to be tested: save informations about the rig along with animation in order to be used to scale animation when loaded 32 | 33 | * Also, it could be interesting to propose the user to remap the names. 34 | 35 | File is: `QuickTransfer.py`. Enjoy ! 36 | -------------------------------------------------------------------------------- /BoxingGame/BoxerModularController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BoxerModularController : MonoBehaviour { 6 | 7 | InputsBoxer inputs; 8 | AIProto ai; 9 | BoxerMoveController move; 10 | BoxerFightController fight; 11 | 12 | // Use this for initialization 13 | void Start () { 14 | 15 | inputs = GetComponent(); 16 | move = GetComponent(); 17 | fight = GetComponent(); 18 | if(!inputs.enabled) 19 | { 20 | ai = GetComponent(); 21 | } 22 | } 23 | 24 | // Update is called once per frame 25 | void Update () { 26 | 27 | ParsePlayerInputs(); 28 | 29 | } 30 | 31 | 32 | public void IAOrder(Command ia_command) 33 | { 34 | move.PlayerMove(ia_command.Direction, ia_command.Dash); 35 | fight.Act(ia_command.Left, ia_command.Right, ia_command.Direct, ia_command.Hook, ia_command.Upper, ia_command.Dodge); 36 | } 37 | 38 | void ParsePlayerInputs() 39 | { 40 | if(inputs.enabled) 41 | { 42 | bool dash = inputs.Dash; 43 | Vector2 direction = inputs.GetDirection(); 44 | 45 | move.PlayerMove(direction, dash); 46 | fight.Act(inputs.Left, inputs.Right, inputs.Direct, inputs.Hook, inputs.Upper, inputs.Dodge); 47 | } 48 | } 49 | 50 | public void Inform(string info) 51 | { 52 | if(info == "Dash") 53 | { 54 | move.ApplyDashForce(); 55 | } 56 | else if(info == "HitEnd") 57 | { 58 | fight.BeReady(); 59 | } 60 | else if(info == "Impulsion") 61 | { 62 | fight.Impulse(); 63 | } 64 | } 65 | 66 | public void SwitchHitbox(string hitbox_name, bool state, bool dodge = false) 67 | { 68 | fight.Switch(hitbox_name, state, dodge); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /God of War- ReMehd/SpecificTimeInformModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SpecificTimeInformModular : StateMachineBehaviour { 6 | 7 | public string Information = "Message to transmit"; 8 | public float NormalizedTime = 0.5f; 9 | 10 | bool ready = true; 11 | 12 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 13 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | ready = true; 15 | } 16 | 17 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 18 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 19 | if(stateInfo.normalizedTime > NormalizedTime && ready) 20 | { 21 | ready = false; 22 | Inform(animator, true); 23 | } 24 | } 25 | 26 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 27 | // override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 28 | // } 29 | 30 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 31 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | // 33 | //} 34 | 35 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 36 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 37 | 38 | // } 39 | 40 | 41 | void Inform(Animator animator, bool state) 42 | { 43 | animator.gameObject.GetComponent().Inform(Information, state); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseSpecificTimeInformModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseSpecificTimeInformModular : StateMachineBehaviour { 6 | 7 | public string Information = "Message to transmit"; 8 | public float NormalizedTime = 0.5f; 9 | 10 | bool ready = true; 11 | 12 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 13 | override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 14 | ready = true; 15 | } 16 | 17 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 18 | override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 19 | if(stateInfo.normalizedTime > NormalizedTime && ready) 20 | { 21 | ready = false; 22 | Inform(animator, true); 23 | } 24 | } 25 | 26 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 27 | // override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 28 | // } 29 | 30 | // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here 31 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 32 | // 33 | //} 34 | 35 | // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here. 36 | // override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { 37 | 38 | // } 39 | 40 | 41 | void Inform(Animator animator, bool state) 42 | { 43 | animator.gameObject.GetComponent().Inform(Information, state); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SkatingGame/CameraSkate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class CameraSkate : MonoBehaviour { 6 | 7 | [Header("\t Basics")] 8 | public Transform Target; 9 | public float DampSpeed = 2; 10 | public float LookFocusSpeed = 5; 11 | public float RotationSpeed = 5; 12 | 13 | Vector3 Offset; 14 | Vector3 velocity= Vector3.zero; 15 | 16 | float angleY = 0; 17 | float angleX = 0; 18 | 19 | // public float Speed = 5; 20 | 21 | Vector3 LookTarget; 22 | Vector3 TargetPos; 23 | 24 | // Use this for initialization 25 | void Start () { 26 | Offset = transform.position - Target.transform.position; 27 | LookTarget = Target.position; 28 | TargetPos = transform.position; 29 | } 30 | 31 | // Update is called once per frame 32 | void Update () { 33 | 34 | float ix = Input.GetAxis("VerCam"); 35 | float iy = Input.GetAxis("HorCam"); 36 | 37 | Vector3 rotated_offset = Rotate(ix*RotationSpeed, iy*RotationSpeed)*Offset; 38 | TargetPos = Target.position + rotated_offset; 39 | AdaptLookTarget(Target.position); 40 | transform.LookAt(LookTarget); 41 | 42 | } 43 | 44 | void FixedUpdate() 45 | { 46 | AdaptPosition(); 47 | } 48 | 49 | void ResetAngles() 50 | { 51 | angleY = 0; 52 | angleX = 0; 53 | } 54 | 55 | void AdaptPosition() 56 | { 57 | transform.position = Vector3.SmoothDamp(transform.position,TargetPos, ref velocity, DampSpeed*Time.deltaTime); 58 | } 59 | 60 | void AdaptLookTarget(Vector3 v) 61 | { 62 | LookTarget = v; 63 | } 64 | 65 | Quaternion Rotate(float x, float y) 66 | { 67 | angleX += x; 68 | angleY += y; 69 | 70 | angleX = Mathf.Clamp(angleX,-45, 45); 71 | Quaternion r = Quaternion.AngleAxis(angleX, transform.right)*Quaternion.AngleAxis(angleY,Vector3.up); 72 | return r; 73 | } 74 | 75 | 76 | } 77 | 78 | -------------------------------------------------------------------------------- /SkatingGame/SkateAnim.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SkateAnim : MonoBehaviour { 6 | 7 | public float AnimationLerpSpeed; 8 | SkateControl control; 9 | InputProcessing inputs; 10 | Animator anim; 11 | 12 | 13 | [HideInInspector] public Quaternion FromInputs; 14 | float Tilt; 15 | bool LastAerial = false; 16 | // Use this for initialization 17 | void Start () { 18 | Initialization(); 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | 24 | ManageTilt(); 25 | ManageAir(); 26 | } 27 | 28 | void ManageAir() 29 | { 30 | bool current_aerial = control.aerial; 31 | if(current_aerial) 32 | { 33 | if(!LastAerial) 34 | { 35 | LastAerial = true; 36 | anim.SetTrigger("Aerial"); 37 | } 38 | } 39 | else 40 | { 41 | if(LastAerial) 42 | { 43 | LastAerial = false; 44 | anim.SetTrigger("Land"); 45 | } 46 | } 47 | } 48 | 49 | void ManageTilt() 50 | { 51 | Vector3 expected_direction = control.VelocityRotation*transform.forward; 52 | float angle = Vector3.SignedAngle(transform.forward, expected_direction, transform.up); 53 | // FromInputs = control.VelocityRotation; 54 | // // float angle = FromInputs.eulerAngles.y - 360; 55 | Debug.Log(angle); 56 | // angle = Mathf.Clamp(Vector3.SignedAngle(forward, adapted_direction, Vector3.up), -90,90); 57 | angle = Mathf.Clamp(angle*3f, -5f,5f); 58 | Tilt = (angle+5f)/10f; 59 | 60 | 61 | AdjustAnim(); 62 | } 63 | 64 | void AdjustAnim() 65 | { 66 | float tilt = anim.GetFloat("Tilt"); 67 | tilt = Mathf.Lerp(tilt, Tilt, AnimationLerpSpeed*Time.deltaTime); 68 | anim.SetFloat("Tilt", tilt); 69 | } 70 | 71 | void Initialization() 72 | { 73 | control = GetComponent(); 74 | anim = GetComponent(); 75 | 76 | Tilt = 0.5f; 77 | anim.SetFloat("Tilt", Tilt); 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseHitImpact.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseHitImpact : MonoBehaviour { 6 | 7 | [Header("0 = Impact | 1 = Hit")] 8 | public int TypeImpact = 0; 9 | public bool Active = false; 10 | public GameObject ImpactEffect; 11 | 12 | TrailRenderer trail; 13 | BaseFight holder; 14 | 15 | [HideInInspector] public BaseHitData current_hit_data; 16 | 17 | // Use this for initialization 18 | void Start () { 19 | Initialization(); 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update () { 25 | 26 | } 27 | 28 | void OnTriggerEnter(Collider other) 29 | { 30 | if(TypeImpact == 0) 31 | { 32 | BaseHitImpact other_hit = other.gameObject.GetComponent(); 33 | if(other_hit != null) 34 | { 35 | if(other_hit.TypeImpact == 1) 36 | { 37 | if(other_hit.Active) 38 | { 39 | Impacted(other_hit, other_hit.current_hit_data); 40 | } 41 | } 42 | } 43 | } 44 | 45 | } 46 | 47 | void Impacted(BaseHitImpact other_hit, BaseHitData impact_hit_data) 48 | { 49 | // Stopping Time 50 | GoWCommon.StopTime(); 51 | 52 | // Visual FX 53 | Vector3 hit_position = other_hit.transform.position; 54 | Vector3 ennemy_position = other_hit.holder.transform.position; 55 | Transform ennemy_transform = other_hit.holder.transform; 56 | GameObject p = Instantiate(ImpactEffect, hit_position, ImpactEffect.transform.rotation) as GameObject; 57 | 58 | // Physical response and animation 59 | holder.Impacted(ennemy_transform, impact_hit_data); 60 | } 61 | 62 | public void Switch(BaseHitData hit_data, bool state) 63 | { 64 | Active = state; 65 | if(Active) 66 | { 67 | current_hit_data = hit_data; 68 | trail.enabled = true; 69 | trail.Clear(); 70 | } 71 | else 72 | { 73 | trail.enabled = false; 74 | } 75 | } 76 | 77 | void Initialization() 78 | { 79 | // SetTrail(); 80 | trail = GetComponent(); 81 | trail.enabled = false; 82 | holder = transform.root.gameObject.GetComponent(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /2.5DController/HitImpact.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class HitImpact : MonoBehaviour { 6 | 7 | [Header("True = Impact | False = Hit")] 8 | public bool TypeImpact = false; 9 | public bool Active = false; 10 | public GameObject ImpactEffect; 11 | 12 | TrailRenderer trail; 13 | FightModule holder; 14 | 15 | [HideInInspector] public float HeavyForce; 16 | [HideInInspector] public float LightForce; 17 | 18 | 19 | // Use this for initialization 20 | void Start () { 21 | 22 | Initialization(); 23 | 24 | 25 | } 26 | 27 | // Update is called once per frame 28 | void Update () { 29 | 30 | } 31 | 32 | void OnTriggerEnter(Collider other) 33 | { 34 | if(TypeImpact) 35 | { 36 | HitImpact other_hit = other.gameObject.GetComponent(); 37 | if(other_hit != null) 38 | { 39 | if(other_hit.Active) 40 | { 41 | Impacted(other.transform.position, other_hit.HeavyForce); 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | void Impacted(Vector3 pos, float force) 49 | { 50 | Debug.Log(force); 51 | GameObject p = Instantiate(ImpactEffect, pos, ImpactEffect.transform.rotation) as GameObject; 52 | holder.Impacted(force); 53 | } 54 | 55 | public void ParticleImpact() 56 | { 57 | Impacted(transform.position, 150); 58 | } 59 | 60 | public void Switch(bool state) 61 | { 62 | Active = state; 63 | if(Active) 64 | { 65 | trail.enabled = true; 66 | } 67 | else 68 | { 69 | trail.enabled = false; 70 | } 71 | } 72 | 73 | void SetTrail() 74 | { 75 | trail = GetComponent(); 76 | if(trail) 77 | { 78 | trail.enabled =false; 79 | } 80 | } 81 | 82 | void Initialization() 83 | { 84 | SetTrail(); 85 | holder = transform.root.gameObject.GetComponent(); 86 | } 87 | 88 | 89 | public void SetForces(float light, float heavy) 90 | { 91 | LightForce = light; 92 | HeavyForce = heavy; 93 | 94 | Debug.Log(HeavyForce); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ModularController/HitImpact.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class HitImpact : MonoBehaviour { 6 | 7 | [Header("True = Impact | False = Hit")] 8 | public bool TypeImpact = false; 9 | public bool Active = false; 10 | public GameObject ImpactEffect; 11 | 12 | TrailRenderer trail; 13 | FightModule holder; 14 | 15 | [HideInInspector] public float HeavyForce; 16 | [HideInInspector] public float LightForce; 17 | 18 | 19 | // Use this for initialization 20 | void Start () { 21 | 22 | Initialization(); 23 | 24 | 25 | } 26 | 27 | // Update is called once per frame 28 | void Update () { 29 | 30 | } 31 | 32 | void OnTriggerEnter(Collider other) 33 | { 34 | if(TypeImpact) 35 | { 36 | HitImpact other_hit = other.gameObject.GetComponent(); 37 | if(other_hit != null) 38 | { 39 | if(other_hit.Active) 40 | { 41 | Impacted(other.transform.position, other_hit.HeavyForce); 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | void Impacted(Vector3 pos, float force) 49 | { 50 | Debug.Log(force); 51 | GameObject p = Instantiate(ImpactEffect, pos, ImpactEffect.transform.rotation) as GameObject; 52 | holder.Impacted(force); 53 | } 54 | 55 | public void ParticleImpact() 56 | { 57 | Impacted(transform.position, 150); 58 | } 59 | 60 | public void Switch(bool state) 61 | { 62 | Active = state; 63 | if(Active) 64 | { 65 | trail.enabled = true; 66 | } 67 | else 68 | { 69 | trail.enabled = false; 70 | } 71 | } 72 | 73 | void SetTrail() 74 | { 75 | trail = GetComponent(); 76 | if(trail) 77 | { 78 | trail.enabled =false; 79 | } 80 | } 81 | 82 | void Initialization() 83 | { 84 | SetTrail(); 85 | holder = transform.root.gameObject.GetComponent(); 86 | } 87 | 88 | 89 | public void SetForces(float light, float heavy) 90 | { 91 | LightForce = light; 92 | HeavyForce = heavy; 93 | 94 | Debug.Log(HeavyForce); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWHitImpact.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWHitImpact : MonoBehaviour { 6 | 7 | [Header("0 = Impact | 1 = Hit")] 8 | public int TypeImpact = 0; 9 | public bool Active = false; 10 | public GameObject ImpactEffect; 11 | 12 | TrailRenderer trail; 13 | GoWFight holder; 14 | 15 | [HideInInspector] public HitData current_hit_data; 16 | 17 | // Use this for initialization 18 | void Start () { 19 | Initialization(); 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update () { 25 | 26 | } 27 | 28 | void OnTriggerEnter(Collider other) 29 | { 30 | if(TypeImpact == 0) 31 | { 32 | GoWHitImpact other_hit = other.gameObject.GetComponent(); 33 | if(other_hit != null) 34 | { 35 | if(other_hit.TypeImpact == 1) 36 | { 37 | if(other_hit.Active) 38 | { 39 | Impacted(other_hit, other_hit.current_hit_data); 40 | } 41 | } 42 | } 43 | } 44 | 45 | } 46 | 47 | void Impacted(GoWHitImpact other_hit, HitData impact_hit_data) 48 | { 49 | // Stopping Time 50 | GoWCommon.StopTime(); 51 | 52 | // Visual FX 53 | Vector3 hit_position = other_hit.transform.position; 54 | Vector3 ennemy_position = other_hit.holder.transform.position; 55 | Transform ennemy_transform = other_hit.holder.transform; 56 | GameObject p = Instantiate(ImpactEffect, hit_position, ImpactEffect.transform.rotation) as GameObject; 57 | 58 | // Physical response and animation 59 | holder.Impacted(ennemy_transform, impact_hit_data); 60 | } 61 | 62 | public void Switch(HitData hit_data, bool state) 63 | { 64 | Active = state; 65 | if(Active) 66 | { 67 | current_hit_data = hit_data; 68 | trail.enabled = true; 69 | } 70 | else 71 | { 72 | trail.enabled = false; 73 | } 74 | } 75 | 76 | void Initialization() 77 | { 78 | // SetTrail(); 79 | trail = GetComponent(); 80 | trail.enabled = false; 81 | holder = transform.root.gameObject.GetComponent(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /God of War- ReMehd/Readme.md: -------------------------------------------------------------------------------- 1 | # Files used in God of War: ReMehd 2 | 3 | 4 | * Scripts 5 | * Animator 6 | * State Machine Behaviour 7 | * Currently used values 8 | 9 | 10 | ### 20/09 Update 11 | 12 | See [blog post](https://mome36.github.io/unity/gamedev/controller/2018/09/21/UTT3-GoW/) 13 | 14 | ### TODO 15 | * Heavy impact animation 16 | * Heavy Hit 17 | 18 | ### 25/08 Update 2 19 | 20 | 1. Added **time stop** on impact. Implemented it as a static function, that is called from any hitbox. See **GoWCommon**. It was however necessary to put it on a empty GameObject in game because I rely on the `Update` function to deduce when to compute when to get time back to normal 21 | 22 | 1. Added direction for hit impact. Allows to shoot ennemy in the air for instance. **Idea**: Figure out a way to adapt gravity and drag when hit. 23 | 24 | 1. Added impact animation support. Created 4 animations impact for San. 25 | 26 | ### 25/08 Update 27 | 28 | 1. **HitData**: A struct used to hold informations on hits. I create a public instance of this struct in each animation state featuring a hit. Data currently consists of 29 | * Hitbox name 30 | * Impulsion force: How much speed this hit adds to the character rb.velocity. **Useful tips**: Backward force to stop sliding 31 | * Impact force: How much force is transmitted to the ennemy on hit 32 | 1. When entering a hit animation state, **HitInfo** state behaviour calls the ModularScript to transmit the corresponding hit info data. This is then passed on to the corresponding hitbox. In case of an impact, the impacted hitbox reads the HitData informations which allows then force application and so on. 33 | 1. Currently, direction of the force is the hitting character forward. **Idea**: Set a vector in the animation hit data to precise hit direction. 34 | 35 | ## Important notes 36 | 1. In **GoWFight**: The end of the file contains several structs used through the various scripts. Notably HitData 37 | 1. The new `CheckMaxSpeed` in **GoWMove** focuses only on horizontal speed. Better results. 38 | 1. Some values I used for the movement script: 39 | 40 | ![Screenshot](GoWValues.png) 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /AnthemController/ShooterController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | public class ShooterController : MonoBehaviour { 7 | 8 | public bool DEBUG = false; 9 | public PersoFillerShooter Filler; 10 | PersoShooter me; 11 | 12 | 13 | bool is_rotating = false; 14 | // Use this for initialization 15 | void Start () { 16 | 17 | me = new PersoShooter(gameObject, Filler, Camera.main); 18 | 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | 24 | me.MAJ(); 25 | 26 | float x = Input.GetAxis("Horizontal"); 27 | float y = Input.GetAxis("Vertical"); 28 | 29 | 30 | me.PlayerMove(x,y); 31 | 32 | if(Input.GetButtonDown("XButton")) 33 | { 34 | me.ActivateJump(); 35 | me.Fly(); 36 | } 37 | 38 | if(Input.GetButtonDown("YButton")) 39 | { 40 | me.ToggleSuperFly(); 41 | } 42 | 43 | // if(!is_rotating) 44 | // { 45 | // TestStepToRotate(); 46 | // } 47 | // else 48 | // { 49 | // Rotate(); 50 | // } 51 | 52 | UseDebug(); 53 | } 54 | 55 | void UseDebug() 56 | { 57 | if(DEBUG) 58 | { 59 | me = new PersoShooter(gameObject, Filler, Camera.main); 60 | DEBUG = false; 61 | } 62 | } 63 | 64 | 65 | void TestStepToRotate() 66 | { 67 | Vector3 v = transform.position - Camera.main.transform.position; 68 | v.y = transform.forward.y; 69 | float angle = Vector3.Angle(transform.forward, v); 70 | if (angle > 30) 71 | { 72 | is_rotating = true; 73 | } 74 | } 75 | 76 | void Rotate() 77 | { 78 | Vector3 v = transform.position - Camera.main.transform.position; 79 | v.y = transform.forward.y; 80 | float angle = Vector3.Angle(transform.forward, v); 81 | if (angle < 2) 82 | { 83 | is_rotating = false; 84 | } 85 | else 86 | { 87 | angle = (Vector3.Dot(transform.right, v) > 0) ? 45:-45; 88 | Quaternion target = transform.rotation*Quaternion.AngleAxis(angle, transform.up); 89 | transform.rotation = Quaternion.Lerp(transform.rotation, target, 5*Time.deltaTime); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /GrassUtility/GrassPatches.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | [System.Serializable] 7 | public class GrassPatch 8 | { 9 | public Vector3 Origin; 10 | public float Radius; 11 | public int Number; 12 | } 13 | // { 14 | // public GameObject g; 15 | // [HideInInspector] 16 | // public Transform place; 17 | // public float Radius; 18 | // public int StrandNumber; 19 | 20 | // List points = new List(); 21 | // List normals = new List (); 22 | // int [] indices; 23 | // bool Ready; 24 | 25 | // Mesh mesh; 26 | // MeshFilter filter; 27 | // MeshRenderer renderer; 28 | 29 | 30 | // public GrassPatch(GameObject G, float r,int d) 31 | // { 32 | // g = G; 33 | // place = g.transform; 34 | // Radius = r; 35 | // StrandNumber = d; 36 | 37 | // Ready = false; 38 | // filter = g.GetComponent(); 39 | 40 | // Debug.Log(filter); 41 | // } 42 | 43 | // public void Generate() 44 | // { 45 | // Debug.Log("Start Generation"); 46 | // Debug.Log(StrandNumber); 47 | // for (int i = 0; i < StrandNumber; i++) 48 | // { 49 | // Debug.Log("Inside"); 50 | // float r = Random.Range(0.0f, Radius); 51 | // float angle = Random.Range(0.0f,360.0f); 52 | // Debug.Log("Before loop 1"); 53 | // Vector3 origin = g.transform.position + 54 | // new Vector3(r*Mathf.Cos(angle),150,r*Mathf.Sin(angle)); 55 | // Debug.Log(origin); 56 | // Ray ray = new Ray(origin, -Vector3.up); 57 | // RaycastHit hit; 58 | // Debug.Log("Before loop"); 59 | // if (Physics.Raycast(ray, out hit)) 60 | // { 61 | // Debug.Log("Hit"); 62 | // points.Add(hit.point); 63 | // indices[i] = i; 64 | // normals.Add(hit.normal); 65 | // } 66 | 67 | // Debug.Log(i); 68 | // } 69 | 70 | // Debug.Log("End Generation"); 71 | // mesh = new Mesh(); 72 | // mesh.SetVertices(points); 73 | // mesh.SetIndices(indices, MeshTopology.Points, 0); 74 | // mesh.SetNormals(normals); 75 | 76 | // Debug.Log(mesh); 77 | // filter.mesh = mesh; 78 | 79 | // Ready = true; 80 | // } 81 | 82 | 83 | 84 | 85 | 86 | 87 | // } -------------------------------------------------------------------------------- /Classes/UtilityNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class UtilityNode 6 | { 7 | public Vector3 Position; 8 | public float Value; 9 | public int index_x; 10 | public int index_y; 11 | 12 | public float Space; 13 | 14 | public float distance_cost = 0; 15 | 16 | public LayerMask NotWalkable; 17 | 18 | 19 | float factor; 20 | float alpha; 21 | 22 | public UtilityNode(Vector3 v, float s, int x, int y, float val, LayerMask l) 23 | { 24 | Position = v; 25 | Value = val; 26 | index_x = x; 27 | index_y = y; 28 | Space = s; 29 | 30 | distance_cost = val; 31 | NotWalkable = l; 32 | } 33 | 34 | public float FromCenter(float half_s) 35 | { 36 | float dx =((float)index_x-half_s + 0.5f); 37 | float dy =((float)index_y-half_s + 0.5f); 38 | return (dx*dx + dy*dy); 39 | } 40 | 41 | public void UpdatePosition(Vector3 center, float space, Vector3 o) 42 | { 43 | Position = center + new Vector3(index_x*space, 0,space*index_y) + o; 44 | } 45 | 46 | public void UpdateValue() 47 | { 48 | Collider [] statics = Physics.OverlapSphere(Position, Space/2.0f, NotWalkable); 49 | if (statics.Length > 0) 50 | { 51 | Value = 1; 52 | } 53 | else if (!Physics.Raycast(Position, Vector3.down, 2*Space)) 54 | { 55 | Value = 1.0f; 56 | } 57 | else 58 | { 59 | Value = distance_cost*alpha + EnnemiCost()*(1-alpha); 60 | // Value = EnnemiCost(); 61 | } 62 | } 63 | 64 | public float EnnemiCost() 65 | { 66 | Collider [] Ennemies = Physics.OverlapSphere(Position, 4*Space); 67 | if (Ennemies.Length > 0) 68 | { 69 | float counter = 0; 70 | for(int i = 0; i()) 74 | { 75 | float d = 1-(Ennemies[i].transform.position - Position).magnitude/(factor*4*Space); 76 | d = Mathf.Clamp01(d); 77 | // float d = 1-((Ennemies[i].transform.position - Position).magnitude/(4*Space)); 78 | counter += d; 79 | } 80 | 81 | } 82 | return counter; 83 | } 84 | return 0.0f; 85 | } 86 | 87 | public void SetWeightFactor(float a) 88 | { 89 | alpha = a; 90 | } 91 | 92 | 93 | 94 | 95 | 96 | 97 | } -------------------------------------------------------------------------------- /GrassUtility/GrassDisperser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [ExecuteInEditMode] 6 | public class GrassDisperser : MonoBehaviour { 7 | 8 | public MeshFilter filter; 9 | public float HeightOffset; 10 | public List grass = new List (); 11 | 12 | Mesh mesh; 13 | 14 | // Use this for initialization 15 | void Start () { 16 | 17 | FillTerrain(); 18 | 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | 24 | } 25 | 26 | void FillTerrain() 27 | { 28 | int maxStrands = 0; 29 | for (int i = 0; i positions = new List(); 36 | int[] indicies = new int[maxStrands]; 37 | List colors = new List(); 38 | List normals = new List(); 39 | 40 | int indices_counter = 0; 41 | 42 | for(int i = 0; i impulsionHolder = new List(); 49 | 50 | [Space(50)] 51 | 52 | [Header("\t\tHitboxes")] 53 | public bool UseHitboxes = false; 54 | public List Hitboxes = new List(); 55 | public List AttackHitboxes = new List (); 56 | 57 | [Space(50)] 58 | 59 | [Header("\t\tSpecial Effects")] 60 | public bool UseSpecialEffects = true; 61 | public List FXHolder = new List(); 62 | 63 | [Space(50)] 64 | 65 | [Header("\t\tAnimation Parameters")] 66 | public List AnimationStates = new List(); 67 | 68 | [Space(30)] 69 | public List CharacterState = new List(); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Controller/TPSCam.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TPSCam : MonoBehaviour 6 | { 7 | public Transform Target; 8 | public float DampSpeed = 2; 9 | 10 | public Vector3 ShootOffset; 11 | 12 | Vector3 Offset; 13 | Vector3 velocity= Vector3.zero; 14 | 15 | float angleY = 0; 16 | float angleX = 0; 17 | 18 | public float Speed = 5; 19 | 20 | bool is_shooting = false; 21 | Vector3 LookTarget; 22 | 23 | public void Start() 24 | { 25 | Offset = transform.position - Target.transform.position; 26 | LookTarget = Target.position; 27 | } 28 | 29 | public void Update() 30 | { 31 | 32 | float ix = Input.GetAxis("VerCam"); 33 | float iy = Input.GetAxis("HorCam"); 34 | 35 | 36 | if (Input.GetAxis("R2") > 0.5f) 37 | { 38 | AdaptLookTarget(Target.position + 5*Target.forward); 39 | AdaptPosition(ShootPos(), DampSpeed/5); 40 | 41 | if(!is_shooting) 42 | { 43 | // ResetAngles(); 44 | is_shooting = true; 45 | } 46 | } 47 | 48 | else 49 | { 50 | if(is_shooting) 51 | { 52 | is_shooting = false; 53 | } 54 | 55 | Vector3 rotated_offset = Rotate(ix*Speed, iy*Speed)*Offset; 56 | AdaptPosition(Target.position + rotated_offset, DampSpeed); 57 | AdaptLookTarget(Target.position); 58 | } 59 | 60 | transform.LookAt(LookTarget); 61 | 62 | } 63 | 64 | void ResetAngles() 65 | { 66 | angleY = 0; 67 | angleX = 0; 68 | } 69 | 70 | void AdaptPosition(Vector3 v, float s) 71 | { 72 | transform.position = Vector3.SmoothDamp(transform.position,v, ref velocity, s*Time.deltaTime); 73 | } 74 | 75 | void AdaptLookTarget(Vector3 v) 76 | { 77 | LookTarget = Vector3.Lerp(LookTarget, v, 5*Time.deltaTime); 78 | } 79 | 80 | Vector3 ShootPos() 81 | { 82 | Vector3 pos = Target.position + Target.forward*ShootOffset.z + Target.right*ShootOffset.x + Target.up*ShootOffset.y; 83 | 84 | return pos; 85 | } 86 | 87 | Quaternion Rotate(float x, float y) 88 | { 89 | angleX += x; 90 | angleY += y; 91 | 92 | angleX = Mathf.Clamp(angleX,-45, 45); 93 | Quaternion r = Quaternion.AngleAxis(angleX, Target.right)*Quaternion.AngleAxis(angleY,Target.up); 94 | return r; 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /2.5DController/FightModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | [System.Serializable] 7 | public class FightModule : MonoBehaviour { 8 | 9 | [Header("\t\t Hit Parameters")] 10 | public float LightForce; 11 | public float HeavyForce; 12 | 13 | 14 | [Header("\t\t Hitboxes")] 15 | public Boxes [] hitboxes; 16 | 17 | [Header("\t\t Shoot Parameters")] 18 | public ShootParticles RayShooter; 19 | 20 | Animator anim; 21 | Rigidbody rb; 22 | Dictionary HitDict; 23 | Dictionary ImpactDict; 24 | 25 | // Use this for initialization 26 | void Start () { 27 | 28 | Initialization(); 29 | 30 | 31 | } 32 | 33 | // Update is called once per frame 34 | void Update () { 35 | 36 | } 37 | 38 | public void Hit(bool hit, bool heavy_hit) 39 | { 40 | if(hit) 41 | { 42 | anim.SetBool("Hit", true); 43 | } 44 | else if(heavy_hit) 45 | { 46 | anim.SetBool("HitHeavy", true); 47 | } 48 | } 49 | 50 | public void Impacted(float force) 51 | { 52 | anim.SetTrigger("Impact"); 53 | rb.AddForce(-transform.forward*force); 54 | } 55 | 56 | public void Shoot() 57 | { 58 | anim.SetTrigger("Shoot"); 59 | } 60 | 61 | public void ShootAction() 62 | { 63 | RayShooter.Shoot(transform); 64 | } 65 | 66 | void FillDicts() 67 | { 68 | HitDict = new Dictionary(); 69 | ImpactDict = new Dictionary(); 70 | foreach(Boxes hit in hitboxes) 71 | { 72 | if(hit.box.TypeImpact) 73 | { 74 | ImpactDict.Add(hit.name, hit.box); 75 | } 76 | else 77 | { 78 | HitDict.Add(hit.name, hit.box); 79 | hit.box.SetForces(LightForce, HeavyForce); 80 | } 81 | } 82 | } 83 | 84 | public void Switch(string entry, bool state) 85 | { 86 | HitDict[entry].Switch(state); 87 | } 88 | 89 | void Initialization() 90 | { 91 | anim = GetComponent(); 92 | rb = GetComponent(); 93 | FillDicts(); 94 | } 95 | } 96 | 97 | [System.Serializable] 98 | public struct Boxes 99 | { 100 | public string name; 101 | public HitImpact box; 102 | } 103 | -------------------------------------------------------------------------------- /ModularController/FightModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | [System.Serializable] 7 | public class FightModule : MonoBehaviour { 8 | 9 | [Header("\t\t Hit Parameters")] 10 | public float LightForce; 11 | public float HeavyForce; 12 | 13 | 14 | [Header("\t\t Hitboxes")] 15 | public Boxes [] hitboxes; 16 | 17 | [Header("\t\t Shoot Parameters")] 18 | public ShootParticles RayShooter; 19 | 20 | Animator anim; 21 | Rigidbody rb; 22 | Dictionary HitDict; 23 | Dictionary ImpactDict; 24 | 25 | // Use this for initialization 26 | void Start () { 27 | 28 | Initialization(); 29 | 30 | 31 | } 32 | 33 | // Update is called once per frame 34 | void Update () { 35 | 36 | } 37 | 38 | public void Hit(bool hit, bool heavy_hit) 39 | { 40 | if(hit) 41 | { 42 | anim.SetBool("Hit", true); 43 | } 44 | else if(heavy_hit) 45 | { 46 | anim.SetBool("HitHeavy", true); 47 | } 48 | } 49 | 50 | public void Impacted(float force) 51 | { 52 | anim.SetTrigger("Impact"); 53 | rb.AddForce(-transform.forward*force); 54 | } 55 | 56 | public void Shoot() 57 | { 58 | anim.SetTrigger("Shoot"); 59 | } 60 | 61 | public void ShootAction() 62 | { 63 | RayShooter.Shoot(transform); 64 | } 65 | 66 | void FillDicts() 67 | { 68 | HitDict = new Dictionary(); 69 | ImpactDict = new Dictionary(); 70 | foreach(Boxes hit in hitboxes) 71 | { 72 | if(hit.box.TypeImpact) 73 | { 74 | ImpactDict.Add(hit.name, hit.box); 75 | } 76 | else 77 | { 78 | HitDict.Add(hit.name, hit.box); 79 | hit.box.SetForces(LightForce, HeavyForce); 80 | } 81 | } 82 | } 83 | 84 | public void Switch(string entry, bool state) 85 | { 86 | HitDict[entry].Switch(state); 87 | } 88 | 89 | void Initialization() 90 | { 91 | anim = GetComponent(); 92 | rb = GetComponent(); 93 | FillDicts(); 94 | } 95 | } 96 | 97 | [System.Serializable] 98 | public struct Boxes 99 | { 100 | public string name; 101 | public HitImpact box; 102 | } 103 | -------------------------------------------------------------------------------- /BoxingGame/RingHitImpact.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RingHitImpact : MonoBehaviour { 6 | 7 | [Header("0 = Impact | 1 = Hit | 2 = Dodge")] 8 | public int TypeImpact = 0; 9 | public bool Active = false; 10 | public GameObject ImpactEffect; 11 | 12 | TrailRenderer trail; 13 | BoxerFightController holder; 14 | 15 | 16 | // Use this for initialization 17 | void Start () { 18 | 19 | Initialization(); 20 | 21 | 22 | } 23 | 24 | // Update is called once per frame 25 | void Update () { 26 | 27 | } 28 | 29 | void OnTriggerEnter(Collider other) 30 | { 31 | // if(TypeImpact) 32 | // { 33 | // RingHitImpact other_hit = other.gameObject.GetComponent(); 34 | // if(other_hit != null) 35 | // { 36 | // if(other_hit.Active) 37 | // { 38 | // Impacted(other.transform.position, 5); 39 | // } 40 | // } 41 | // } 42 | 43 | 44 | if(TypeImpact == 0) 45 | { 46 | RingHitImpact other_hit = other.gameObject.GetComponent(); 47 | if(other_hit != null) 48 | { 49 | if(other_hit.TypeImpact == 1) 50 | { 51 | if(other_hit.Active) 52 | { 53 | Impacted(other.transform.position, 5); 54 | } 55 | } 56 | } 57 | } 58 | 59 | } 60 | 61 | void Impacted(Vector3 pos, float force) 62 | { 63 | GameObject p = Instantiate(ImpactEffect, pos, ImpactEffect.transform.rotation) as GameObject; 64 | holder.Impacted(force); 65 | } 66 | 67 | public void ParticleImpact() 68 | { 69 | Impacted(transform.position, 150); 70 | } 71 | 72 | public void Switch(bool state) 73 | { 74 | Active = state; 75 | if(Active) 76 | { 77 | trail.enabled = true; 78 | } 79 | else 80 | { 81 | trail.enabled = false; 82 | } 83 | } 84 | 85 | void SetTrail() 86 | { 87 | trail = GetComponent(); 88 | if(trail) 89 | { 90 | trail.enabled =false; 91 | } 92 | } 93 | 94 | void Initialization() 95 | { 96 | SetTrail(); 97 | holder = transform.root.gameObject.GetComponent(); 98 | } 99 | 100 | 101 | public void SetForces(float light, float heavy) 102 | { 103 | // LightForce = light; 104 | // HeavyForce = heavy; 105 | 106 | // Debug.Log(HeavyForce); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Classes/UtilityMap.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class UtilityMap 6 | { 7 | [HideInInspector] 8 | public Vector3 Center; 9 | public int Size; 10 | public float Space; 11 | public LayerMask NotWalkable; 12 | [HideInInspector] 13 | public UtilityNode [] nodes; 14 | 15 | int iterator = 0; 16 | Vector3 Offset; 17 | float MaxMagnitude; 18 | 19 | public UtilityMap(Vector3 v, int n, float f, LayerMask l) 20 | { 21 | Center = v; 22 | Size = n; 23 | Space = f; 24 | NotWalkable = l; 25 | 26 | float fsize = (float)Size; 27 | MaxMagnitude = fsize*1.41f; 28 | nodes = new UtilityNode [Size*Size]; 29 | Offset = new Vector3(-(fsize-1)/2.0f*Space,0,-(fsize-1)/2.0f*Space); 30 | 31 | Setup(); 32 | } 33 | 34 | void Setup() 35 | { 36 | 37 | 38 | int counter = 0; 39 | for (int i = 0; i 0.5f) 38 | { 39 | AdaptLookTarget(Target.position + 5*Target.forward); 40 | AdaptPosition(ShootPos(), DampSpeed/5); 41 | 42 | if(!is_shooting) 43 | { 44 | // ResetAngles(); 45 | is_shooting = true; 46 | } 47 | } 48 | 49 | else 50 | { 51 | if(is_shooting) 52 | { 53 | is_shooting = false; 54 | } 55 | 56 | Vector3 rotated_offset = Rotate(ix*Speed, iy*Speed)*Offset; 57 | AdaptPosition(Target.position + rotated_offset, DampSpeed); 58 | AdaptLookTarget(Target.position); 59 | } 60 | 61 | 62 | } 63 | 64 | void LateUpdate() 65 | { 66 | transform.LookAt(LookTarget); 67 | } 68 | 69 | void ResetAngles() 70 | { 71 | angleY = 0; 72 | angleX = 0; 73 | } 74 | 75 | void AdaptPosition(Vector3 v, float s) 76 | { 77 | transform.position = Vector3.SmoothDamp(transform.position,v, ref velocity, s*Time.deltaTime); 78 | } 79 | 80 | void AdaptLookTarget(Vector3 v) 81 | { 82 | // LookTarget = Vector3.Lerp(LookTarget, v, LookFocusSpeed*Time.deltaTime); 83 | LookTarget = v; 84 | } 85 | 86 | Vector3 ShootPos() 87 | { 88 | Vector3 pos = Target.position + Target.forward*ShootOffset.z + Target.right*ShootOffset.x + Target.up*ShootOffset.y; 89 | 90 | return pos; 91 | } 92 | 93 | Quaternion Rotate(float x, float y) 94 | { 95 | angleX += x; 96 | angleY += y; 97 | 98 | angleX = Mathf.Clamp(angleX,-45, 45); 99 | Quaternion r = Quaternion.AngleAxis(angleX, Target.right)*Quaternion.AngleAxis(angleY,Target.up); 100 | return r; 101 | } 102 | 103 | 104 | } 105 | -------------------------------------------------------------------------------- /BlenderRigForUnity/Readme.md: -------------------------------------------------------------------------------- 1 | # Blender Procedural Animation 2 | 3 | # I. Rig 4 | 5 | Using `ArmatureUnity.py` will create a rig with IK constraint ready for Unity Mecanim. 6 | Script could be optimized, but works okay for now 7 | 8 | # II. Animation 9 | 10 | Efforts have been put into a script that can generate automatic animations. Here's how it works: 11 | 12 | * The script creates a class based on the armature generated by `ArmatureUnity.py` 13 | * If you need to create more animations, you'll have to set an initial pose, which is the T-pose (because this program computes the difference between current pose and initial pose). In this case, run the script once with the argument `load = False`. Make sure you specify the path in the initialization of the instance. 14 | * Methods are being designed to create keyframes of animation, theoretically usable over many different sized rigs because description of the movement is based on arms and legs length 15 | 16 | ### To record more animation: 17 | 18 | Create your animation as usual, using keyframes. Then, for each step, use the `print_pose` method to get a log on the console with what you should copy in a new method. This implies running the script multiple times with the initial pose recorded. I'll try to post a tutorial soon but basically: 19 | 20 | 1. Run the script for the first time with `load = False`. Create the initial pose data (this saves a pickle file in the path chosen) 21 | 1. For an smoother workflow, create your full animation in a temporary action data 22 | 1. For each frame where a keyframe is inserted do the following: 23 | 1. Move the cursor to the frame. Run the script with `load = True` (make sure the only method called is `print_pose`) 24 | 1. In the terminal, you'll see a print which you just need to copy and paste in your animation method 25 | 1. After pasting, call the confirmation method, and specify number of frames to move on forward 26 | 1. Move on to the next keyframe 27 | 28 | You can use existing animations methods for example and inspiration. 29 | Of course, the workflow could be improved and I'm thinking about it. 30 | 31 | ### To use the animations already created: 32 | 33 | Modify the script: 34 | * Comment`print_pose()` method 35 | * Call whichever animation method you wish. For instance `RunMale`, `IdleCombat`... 36 | 37 | 38 | # To do: 39 | * Think of a better way to structure the code. One idea would be to record movements in pickable objects rather than writing them in code 40 | * Is it possible to use the F-curves ? 41 | 42 | * Add path selection in the main method 43 | 44 | -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/Saver.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import random 3 | import math 4 | import mathutils as m 5 | import pickle 6 | 7 | # def set_frame(nb): 8 | # bpy.context.scene.frame_current = nb 9 | 10 | 11 | curve_dico = {0: 'LocX', 12 | 1: 'LocY', 13 | 2: 'LocZ', 14 | 3: 'RotW', 15 | 4: 'RotX', 16 | 5: 'RotY', 17 | 6: 'RotZ' 18 | } 19 | 20 | 21 | class Point(): 22 | 23 | def __init__(self, point, ratio): 24 | 25 | self.point = [c/ratio for c in point.co] 26 | self.left_handle = [c/ratio for c in point.handle_left] 27 | self.right_handle = [c/ratio for c in point.handle_right] 28 | 29 | def __repr__(self): 30 | 31 | s = 'Points {}\nLeft handle {}\nRight handle {}\n\n '.format(self.point, self.left_handle, self.right_handle) 32 | return s 33 | 34 | 35 | class CurveStructure(): 36 | 37 | def __init__(self,c, action_name, bone_nb, curve_number, ratio = 1.): 38 | 39 | self.name = 'Action {} - Bone {} - Curve {} '.format(action_name, bone_nb, curve_dico[curve_number]) 40 | self.frames = [int(k.co.x) for k in c.keyframe_points] 41 | self.points = [] 42 | 43 | self.name += '- Keyframes {} \n\n'.format(self.frames) 44 | 45 | for k in c.keyframe_points: 46 | self.points.append(Point(k, ratio)) 47 | 48 | def __repr__(self): 49 | 50 | return self.name 51 | 52 | 53 | class StructureSaver(): 54 | 55 | def __init__(self,name, curves, armature): 56 | 57 | self.name = name 58 | self.nb_bones = int(len(curves)/7) 59 | 60 | self.bones = armature.bones_names 61 | 62 | leg_length = armature.leg_length 63 | arm_length = armature.arm_length 64 | 65 | self.curves = [] 66 | for i,c in enumerate(curves): 67 | try: 68 | current_name = self.bones[int(i/7)] 69 | except IndexError: 70 | print('Exiting before registering other bones') 71 | break 72 | 73 | ratio = 1. 74 | if i%7 < 3: 75 | if current_name in armature.leg_sensitive: 76 | print('Current bone {} is leg sensitive. Apply ratio of {:.3f} for {}'.format(current_name, leg_length, curve_dico[i%7])) 77 | ratio = leg_length 78 | if current_name in armature.arm_sensitive: 79 | print('Current bone {} is leg sensitive. Apply ratio of {:.3f} for {}'.format(current_name, arm_length, curve_dico[i%7])) 80 | ratio = arm_length 81 | self.curves.append(CurveStructure(c, name, int(i/7), i%7, ratio)) 82 | 83 | # for c in self.curves: 84 | # print(c) 85 | 86 | self.infos =[leg_length, arm_length] 87 | 88 | def save(self,path): 89 | 90 | pickle.dump(self.curves, open(path, 'wb')) 91 | print('Data saved') -------------------------------------------------------------------------------- /God of War- ReMehd/GoWModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWModular : MonoBehaviour { 6 | 7 | GoWFight fight; 8 | GoWInputs inputs; 9 | GoWMove move; 10 | GoWAxeControl axe_control; 11 | 12 | public bool is_IA = false; 13 | bool jump_control = false; 14 | 15 | // Use this for initialization 16 | void Start () { 17 | 18 | if (!is_IA) 19 | inputs = GetComponent(); 20 | fight = GetComponent(); 21 | move = GetComponent(); 22 | axe_control = GetComponent(); 23 | 24 | } 25 | 26 | // Update is called once per frame 27 | void Update () { 28 | 29 | 30 | if(is_IA) 31 | IAControl(); 32 | else 33 | PlayerControl(); 34 | 35 | ContinuousInformations(); 36 | 37 | } 38 | 39 | void IAControl() 40 | { 41 | 42 | } 43 | 44 | void PlayerControl() 45 | { 46 | 47 | Vector2 direction = inputs.GetDirection(); 48 | move.PlayerMove(direction, inputs.Jump); 49 | 50 | if(inputs.Hit) 51 | fight.Hit(); 52 | 53 | if(inputs.Throw) 54 | axe_control.Throw(); 55 | 56 | if(inputs.CallAxe) 57 | axe_control.CallAxe(); 58 | 59 | if(inputs.ChangeWeapon) 60 | axe_control.ChangeWeapon(); 61 | 62 | 63 | } 64 | 65 | void ContinuousInformations() 66 | { 67 | if(jump_control) 68 | { 69 | move.JumpControl(); 70 | } 71 | } 72 | 73 | public void Inform(string info, bool state) 74 | { 75 | if(info == "Dash") 76 | { 77 | // move.DashMove(); 78 | move.SwitchDash(state); 79 | 80 | } 81 | // if(info == "Shoot") 82 | // { 83 | // fight.ShootAction(); 84 | // } 85 | if(info == "JumpControl") 86 | { 87 | jump_control = state; 88 | } 89 | 90 | if(info == "GetAxeOver" && !state) // !state to make sure we're exiting the state 91 | { 92 | axe_control.GetAxeOver(); // This function sets animation layer 1 weight to 0 93 | } 94 | 95 | if(info == "ReleaseAxe") 96 | { 97 | axe_control.ReleaseAxe(); 98 | } 99 | 100 | if(info == "ChangeAxeParent") 101 | { 102 | axe_control.ChangeAxeParent(); 103 | } 104 | } 105 | 106 | public void HitInform(HitData hit_data, bool state) 107 | { 108 | fight.Switch(hit_data, state); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/Loader.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import random 3 | import math 4 | import mathutils as m 5 | import pickle 6 | 7 | curve_dico = {0: 'LocX', 8 | 1: 'LocY', 9 | 2: 'LocZ', 10 | 3: 'RotW', 11 | 4: 'RotX', 12 | 5: 'RotY', 13 | 6: 'RotZ' 14 | } 15 | 16 | def set_frame(nb): 17 | bpy.context.scene.frame_current = nb 18 | 19 | 20 | def Load(path_to_data, armature, name): 21 | 22 | curves = pickle.load(open(path_to_data, 'rb')) 23 | # curves = data[0] 24 | # infos = data[1] 25 | 26 | current_leg_length = armature.leg_length 27 | current_arm_length = armature.arm_length 28 | 29 | all_bones = armature.bones_names 30 | 31 | # ratio_arm = infos[1]/current_arm_length 32 | # ratio_leg = infos[0]/current_leg_length 33 | 34 | # print('Ratio Arms {} -- Legs {}'.format(ratio_arm, ratio_leg)) 35 | 36 | print('Curves: {} -- Bones {}'.format(len(curves), len(curves)/7)) 37 | 38 | armature.create_action(name) 39 | source_curves = armature.get_curves() 40 | 41 | # reset all 42 | bpy.ops.pose.select_all(action = 'SELECT') 43 | bpy.ops.pose.loc_clear() 44 | bpy.ops.pose.rot_clear() 45 | 46 | set_frame(0) 47 | 48 | # Add one frame for curves 49 | 50 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__', confirm_success = True) 51 | 52 | # add frames for each curve 53 | 54 | for i in range(len(armature.bones_names)): 55 | index = i*7 # make sure to iterate well (7 curves per bone) 56 | keyframes = curves[index].frames 57 | name = armature.select_index(i) # select bone for adding frames for the 7 curves in the same time 58 | 59 | for k in keyframes: 60 | set_frame(k) 61 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__') 62 | # print('Bone {} - Adding keyframe {} '.format(name, k)) 63 | 64 | # Flat curves are set up. 65 | # Now, time to move the control points and handles 66 | 67 | courbe = 0 68 | for c_s, c_t in zip(source_curves, curves): 69 | ratio = 1. 70 | current_bone = all_bones[int(courbe/7)] 71 | if courbe%7 <3: 72 | if current_bone in armature.leg_sensitive: 73 | ratio = current_leg_length 74 | elif current_bone in armature.arm_sensitive: 75 | ratio = current_arm_length 76 | 77 | 78 | for idx,kf in enumerate(c_s.keyframe_points): 79 | # print('Courbe {} -- Point {} '.format(courbe, idx)) 80 | ref = c_t.points[idx] 81 | kf.co.y = ref.point[1]*ratio 82 | kf.handle_left = m.Vector(ref.left_handle) 83 | kf.handle_right = m.Vector(ref.right_handle) 84 | 85 | kf.handle_left.y *= ratio 86 | kf.handle_right.y *= ratio 87 | kf.handle_left.x *= ratio 88 | kf.handle_right.x *= ratio 89 | 90 | 91 | courbe += 1 92 | 93 | -------------------------------------------------------------------------------- /God of War- ReMehd/GoWAxeControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | // Good values: Rotation in back: 8.4, 77, 90 7 | // Vector 0, 0.15, -0.4 8 | 9 | public class GoWAxeControl : MonoBehaviour { 10 | 11 | [Space(10)] 12 | [Header("Axe references")] 13 | public GameObject Axe; 14 | public AxeBehaviour axe_behaviour; 15 | 16 | 17 | public float LerpSpeed; 18 | 19 | Animator anim; 20 | 21 | float current_layer_weight; 22 | float lerp_target; 23 | bool is_lerping; 24 | bool is_changing; 25 | bool is_ready = true; 26 | 27 | 28 | void Start() 29 | { 30 | Initialization(); 31 | } 32 | 33 | void Update() 34 | { 35 | 36 | 37 | } 38 | 39 | public void ChangeAxeParent() 40 | { 41 | axe_behaviour.ChangeParent("kratos"); 42 | anim.SetBool("HasAxe", axe_behaviour.IsInHand()); 43 | } 44 | 45 | void Initialization() 46 | { 47 | anim = GetComponent(); 48 | anim.SetBool("HasAxe", axe_behaviour.IsInHand()); 49 | } 50 | 51 | public void ChangeWeapon() 52 | { 53 | if(is_ready) 54 | { 55 | bool is_in_hand = axe_behaviour.IsInHand(); 56 | bool is_in_back = axe_behaviour.IsInBack(); 57 | 58 | if(is_in_hand || is_in_back) 59 | { 60 | anim.SetTrigger("GetWeapon"); 61 | is_ready = false; 62 | anim.SetLayerWeight(1, 1f); 63 | } 64 | } 65 | } 66 | 67 | public void Throw() 68 | { 69 | if(axe_behaviour.IsInHand()) 70 | { 71 | anim.SetTrigger("Throw"); 72 | } 73 | } 74 | 75 | public void ReleaseAxe() 76 | { 77 | axe_behaviour.Throw(transform.forward); 78 | anim.SetBool("HasAxe", false); 79 | } 80 | 81 | 82 | public void GetAxeOver() 83 | { 84 | is_ready = true; 85 | anim.SetLayerWeight(1, 0f); 86 | } 87 | 88 | public void CallAxe() 89 | { 90 | if(!axe_behaviour.IsInHand()) 91 | { 92 | anim.SetTrigger("ExpectAxe"); 93 | lerp_target = 1f; 94 | is_lerping = true; 95 | anim.SetLayerWeight(1,1f); 96 | 97 | axe_behaviour.Recall(); 98 | } 99 | } 100 | 101 | public void ReceiveAxe() 102 | { 103 | Debug.Log("Reception called"); 104 | lerp_target = 0f; 105 | is_lerping = true; 106 | anim.SetTrigger("ReceiveAxe"); 107 | anim.SetBool("HasAxe", true); 108 | anim.SetLayerWeight(1,0f); 109 | } 110 | 111 | 112 | } 113 | 114 | 115 | // [System.Serializable] 116 | // public struct BakedPosition 117 | // { 118 | // public Vector3 PosOffset; 119 | // public Vector3 EulerRotOffset; 120 | // [HideInInspector] public Quaternion RotOffset; 121 | 122 | // } 123 | -------------------------------------------------------------------------------- /GrassUtility/GrassPointCloudRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [ExecuteInEditMode] 6 | public class GrassPointCloudRenderer : MonoBehaviour { 7 | 8 | //public Mesh grassMesh; 9 | //public Material material; 10 | 11 | private Mesh mesh; 12 | public MeshFilter filter; 13 | 14 | public int seed; 15 | public Vector2 size; 16 | public float radius; 17 | 18 | [Range(1, 60000)] 19 | public int grassNumber; 20 | 21 | public float startHeight = 1000; 22 | public float grassOffset; 23 | 24 | private Vector3 lastPosition; 25 | private List materices; 26 | 27 | // Update is called once per frame 28 | void Update() 29 | { 30 | if (lastPosition != this.transform.position) 31 | { 32 | Random.InitState(seed); 33 | List positions = new List(grassNumber); 34 | int[] indicies = new int[grassNumber]; 35 | List colors = new List(grassNumber); 36 | List normals = new List(grassNumber); 37 | for (int i = 0; i < grassNumber; ++i) 38 | { 39 | float r = Random.Range(-radius,radius); 40 | float angle = Random.Range(0,360); 41 | Vector3 origin = transform.position; 42 | origin.y = startHeight; 43 | origin.x += r*Mathf.Cos(angle); 44 | origin.z += r*Mathf.Sin(angle); 45 | Ray ray = new Ray(origin, Vector3.down); 46 | RaycastHit hit; 47 | if (Physics.Raycast(ray, out hit)) 48 | { 49 | origin = hit.point; 50 | origin.y = hit.point.y + grassOffset; 51 | origin.x -= this.transform.position.x; 52 | origin.z -= this.transform.position.z; 53 | 54 | positions.Add(origin); 55 | indicies[i] = i; 56 | colors.Add(new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), 1)); 57 | normals.Add(hit.normal); 58 | } 59 | } 60 | mesh = new Mesh(); 61 | mesh.SetVertices(positions); 62 | mesh.SetIndices(indicies, MeshTopology.Points, 0); 63 | mesh.SetColors(colors); 64 | mesh.SetNormals(normals); 65 | filter.mesh = mesh; 66 | 67 | lastPosition = this.transform.position; 68 | } 69 | //Graphics.DrawMeshInstanced(grassMesh, 0, material, materices); 70 | } 71 | 72 | void OnDrawGizmos() 73 | { 74 | Gizmos.DrawWireSphere(transform.position, radius); 75 | } 76 | } -------------------------------------------------------------------------------- /BoxingGame/BoxerFightController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BoxerFightController : MonoBehaviour { 6 | 7 | public float ImpulsionStrength = 1f; 8 | public RingNamedHitbox [] Hitboxes; 9 | [HideInInspector] public bool Ready; 10 | Animator anim; 11 | Rigidbody rb; 12 | 13 | Dictionary hit_dict; 14 | Dictionary impact_dict; 15 | Dictionary dodge_dict; 16 | 17 | // Use this for initialization 18 | void Start () { 19 | 20 | FillDicts(); 21 | anim = GetComponent(); 22 | rb = GetComponent(); 23 | Ready = true; 24 | 25 | } 26 | 27 | // Update is called once per frame 28 | void Update () { 29 | 30 | } 31 | 32 | public void Act(bool Left, bool Right, bool Direct, bool Hook, bool Upper, bool Dodge) 33 | { 34 | if(Ready) 35 | { 36 | string side = Right ? "Right" : "Left"; 37 | if(Direct) 38 | { 39 | LaunchHit(side, "Direct"); 40 | } 41 | else if(Hook) 42 | { 43 | LaunchHit(side, "Hook"); 44 | } 45 | else if(Upper) 46 | { 47 | LaunchHit(side, "Upper"); 48 | } 49 | else if(Dodge) 50 | { 51 | LaunchHit(side, "Dodge"); 52 | } 53 | } 54 | } 55 | public void Impulse() 56 | { 57 | rb.velocity += transform.forward*ImpulsionStrength; 58 | } 59 | 60 | public void Impacted(float force) 61 | { 62 | anim.SetTrigger("Impact"); 63 | } 64 | 65 | void LaunchHit(string side, string hit) 66 | { 67 | Debug.Log(side + " " + hit); 68 | anim.SetBool(side, true); 69 | anim.SetTrigger(hit); 70 | Ready = false; 71 | } 72 | 73 | public void BeReady() 74 | { 75 | Ready = true; 76 | } 77 | 78 | public void Switch(string entry, bool state, bool dodge) 79 | { 80 | if(dodge) 81 | dodge_dict[entry].Switch(state); 82 | else 83 | hit_dict[entry].Switch(state); 84 | } 85 | 86 | void FillDicts() 87 | { 88 | hit_dict = new Dictionary(); 89 | impact_dict = new Dictionary(); 90 | dodge_dict = new Dictionary(); 91 | foreach(RingNamedHitbox hit in Hitboxes) 92 | { 93 | if(hit.Box.TypeImpact == 0) 94 | { 95 | impact_dict.Add(hit.Name, hit.Box); 96 | } 97 | else if(hit.Box.TypeImpact == 1) 98 | { 99 | hit_dict.Add(hit.Name, hit.Box); 100 | // hit.box.SetForces(LightForce, HeavyForce); 101 | } 102 | else 103 | { 104 | dodge_dict.Add(hit.Name, hit.Box); 105 | } 106 | } 107 | } 108 | } 109 | 110 | [System.Serializable] 111 | public struct RingNamedHitbox 112 | { 113 | public string Name; 114 | public RingHitImpact Box; 115 | } -------------------------------------------------------------------------------- /God of War- ReMehd/GoWFight.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GoWFight : MonoBehaviour { 6 | 7 | [Header("\t\t Hitboxes")] 8 | public Boxes [] hitboxes; 9 | 10 | Dictionary HitDict; 11 | Dictionary ImpactDict; 12 | 13 | public bool is_hitting; 14 | 15 | Animator anim; 16 | Rigidbody rb; 17 | 18 | // Use this for initialization 19 | void Start () { 20 | 21 | Initialization(); 22 | 23 | } 24 | 25 | // Update is called once per frame 26 | void Update () { 27 | 28 | } 29 | 30 | public void Hit() 31 | { 32 | anim.SetTrigger("Hit"); 33 | } 34 | 35 | void FillDicts() 36 | { 37 | HitDict = new Dictionary(); 38 | ImpactDict = new Dictionary(); 39 | foreach(Boxes hit in hitboxes) 40 | { 41 | if(hit.box.TypeImpact == 0) 42 | { 43 | ImpactDict.Add(hit.name, hit.box); 44 | } 45 | else if(hit.box.TypeImpact == 1) 46 | { 47 | HitDict.Add(hit.name, hit.box); 48 | } 49 | } 50 | } 51 | 52 | public void Switch(HitData hit_data, bool state) 53 | { 54 | HitDict[hit_data.BoxName].Switch(hit_data, state); 55 | if(state) 56 | { 57 | ApplyHitImpulsion(hit_data); 58 | is_hitting = true; 59 | } 60 | else 61 | { 62 | is_hitting = false; 63 | } 64 | } 65 | 66 | public void ApplyHitImpulsion(HitData hd) 67 | { 68 | rb.velocity += transform.forward*hd.ImpulsionStrength; 69 | } 70 | 71 | public void Impacted(Transform ennemy_transform, HitData impact_hit_data) 72 | { 73 | // Vector3 direction = Vector3.ProjectOnPlane(transform.position - pos, Vector3.up).normalized; 74 | Vector3 direction_parameters = impact_hit_data.DirectionComponents; 75 | 76 | Vector3 direction = ennemy_transform.forward*direction_parameters.z + 77 | ennemy_transform.up*direction_parameters.y + 78 | ennemy_transform.right*direction_parameters.x; 79 | 80 | rb.velocity += direction.normalized*impact_hit_data.ImpactForce; 81 | 82 | 83 | anim.SetTrigger(impact_hit_data.ImpactTriggerName); 84 | } 85 | 86 | void Initialization() 87 | { 88 | anim = GetComponent(); 89 | rb = GetComponent(); 90 | 91 | is_hitting = false; 92 | 93 | FillDicts(); 94 | } 95 | 96 | 97 | } 98 | 99 | [System.Serializable] 100 | public struct Boxes 101 | { 102 | public string name; 103 | public GoWHitImpact box; 104 | } 105 | 106 | [System.Serializable] 107 | public struct HitData 108 | { 109 | public string BoxName; 110 | public float ImpulsionStrength; 111 | public float ImpactForce; 112 | public Vector3 DirectionComponents; 113 | public string ImpactTriggerName; 114 | 115 | public string ToString() 116 | { 117 | return "Hit impact " + BoxName + " Impulsion: " + ImpulsionStrength.ToString() + " ImpactStrength: " + ImpactForce.ToString(); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Classes/GradientNavigation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | 7 | // ----------------------------------------------- 8 | 9 | // TO USE THIS CLASS 10 | // Using this class implies having some way of moving and rotation the 11 | // submitted character. This class only computes a direction toward which the character should 12 | // go in order to reach its target and staying away from walls. 13 | 14 | 15 | // ----------------------------------------------- 16 | 17 | 18 | [System.Serializable] 19 | public class GradientNavigation 20 | { 21 | public float MaxDistance = 15; 22 | public int MaxObstacles = 10; 23 | public float AngleIncrement = 5; 24 | public float MaxAngle = 60; 25 | public float ForgetTime = 1.0f; 26 | 27 | public float Repulsion = 1.0f; 28 | 29 | 30 | int iterator = 0; 31 | 32 | float angle = 0; 33 | Vector3 [] Obstacles; 34 | float [] TimeToForget; 35 | 36 | 37 | public GradientNavigation() 38 | { 39 | Obstacles = new Vector3 [MaxObstacles]; 40 | TimeToForget = new float [MaxObstacles]; 41 | } 42 | 43 | 44 | public void Look(Transform transform) 45 | { 46 | Quaternion rot = Quaternion.AngleAxis(angle, transform.up); 47 | Vector3 direction = rot*transform.forward; 48 | 49 | Ray ray = new Ray(transform.position, direction); 50 | RaycastHit hit; 51 | 52 | 53 | 54 | if(Physics.Raycast(ray, out hit, MaxDistance)) 55 | { 56 | Obstacles[iterator] = transform.position - hit.point; 57 | TimeToForget[iterator] = ForgetTime; 58 | // Debug.DrawRay(ray.origin, ray.direction*(transform.position - hit.point).magnitude, Color.red,1.0f); 59 | } 60 | // else 61 | // { 62 | // Debug.DrawRay(ray.origin, ray.direction*MaxDistance, Color.red,1.0f); 63 | // } 64 | 65 | iterator = (iterator + 1)%MaxObstacles; 66 | angle += AngleIncrement; 67 | angle = (angle > MaxAngle) ? -MaxAngle+Random.Range(1,7) : angle; 68 | } 69 | 70 | public void Forget() 71 | { 72 | TimeToForget[iterator] -= Time.deltaTime*MaxObstacles; 73 | if(TimeToForget[iterator] <= 0.0f) 74 | 75 | Obstacles[iterator] = Vector3.zero; 76 | } 77 | 78 | public Vector3 ComputeDirection(Vector3 direction) 79 | { 80 | Vector3 somme = Vector3.zero; 81 | foreach(Vector3 v in Obstacles) 82 | { 83 | if( v.magnitude > 0) 84 | somme += v.normalized/v.magnitude; 85 | } 86 | 87 | return somme; 88 | } 89 | 90 | public Vector3 Navigate(Transform transform, Vector3 dir) 91 | { 92 | Look(transform); 93 | Forget(); 94 | Vector3 v = ComputeDirection(dir); 95 | 96 | // Debug.DrawRay(transform.position, v*5, Color.red, 1.0f); 97 | // Debug.DrawRay(transform.position, dir.normalized*5, Color.green, 1.0f); 98 | 99 | Vector3 sum = Repulsion*v + dir; 100 | return sum.normalized; 101 | } 102 | 103 | 104 | public Vector3 [] DebugVec() 105 | { 106 | return Obstacles; 107 | } 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | } -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseModular.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseModular : MonoBehaviour { 6 | 7 | BaseFight fight; 8 | BaseInputs inputs; 9 | BaseMove move; 10 | // GoWAxeControl axe_control; 11 | 12 | public bool is_IA = false; 13 | bool jump_control = false; 14 | 15 | // Use this for initialization 16 | void Start () { 17 | 18 | if (!is_IA) 19 | inputs = GetComponent(); 20 | fight = GetComponent(); 21 | move = GetComponent(); 22 | // axe_control = GetComponent(); 23 | 24 | } 25 | 26 | // Update is called once per frame 27 | void Update () { 28 | 29 | 30 | if(is_IA) 31 | IAControl(); 32 | else 33 | PlayerControl(); 34 | 35 | ContinuousInformations(); 36 | 37 | 38 | // AJOUTER AXE AIM: FINIR ANIMATIONS + LOGIQUE. DANS GOWFIGHT ? 39 | 40 | } 41 | 42 | void IAControl() 43 | { 44 | 45 | } 46 | 47 | void PlayerControl() 48 | { 49 | 50 | Vector2 direction = inputs.GetDirection(); 51 | move.PlayerMove(direction, inputs.Jump, inputs.HighSpeed); 52 | fight.HoldThrow(inputs.HoldThrow); 53 | 54 | if(inputs.Hit) 55 | fight.Hit(); 56 | 57 | // if(inputs.Throw) 58 | // axe_control.Throw(); 59 | 60 | // if(inputs.CallAxe) 61 | // axe_control.CallAxe(); 62 | 63 | // if(inputs.ChangeWeapon) 64 | // axe_control.ChangeWeapon(); 65 | 66 | } 67 | 68 | void ContinuousInformations() 69 | { 70 | if(jump_control) 71 | { 72 | move.JumpControl(); 73 | } 74 | } 75 | 76 | public void Inform(string info, bool state) 77 | { 78 | if(info == "Dash") 79 | { 80 | // move.DashMove(); 81 | move.DashState(state); 82 | move.SwitchDash(state); 83 | } 84 | // if(info == "Shoot") 85 | // { 86 | // fight.ShootAction(); 87 | // } 88 | if(info == "JumpControl") 89 | { 90 | jump_control = state; 91 | } 92 | 93 | // if(info == "GetAxeOver" && !state) // !state to make sure we're exiting the state 94 | // { 95 | // axe_control.GetAxeOver(); // This function sets animation layer 1 weight to 0 96 | // } 97 | 98 | // if(info == "ReleaseAxe") 99 | // { 100 | // axe_control.ReleaseAxe(); 101 | // } 102 | 103 | // if(info == "ChangeAxeParent") 104 | // { 105 | // axe_control.ChangeAxeParent(); 106 | // } 107 | 108 | if(info == "MoveState") 109 | { 110 | move.MoveState(state); 111 | } 112 | if(info == "HighSpeedState") 113 | { 114 | move.HighSpeedState(state); 115 | } 116 | 117 | if(info == "PrepareThrowState") 118 | { 119 | move.PrepareThrowState(state); 120 | } 121 | 122 | if(info == "UpperCoordination") 123 | { 124 | fight.UpperCoordination(state); 125 | } 126 | 127 | } 128 | 129 | public void HitInform(BaseHitData hit_data, bool state) 130 | { 131 | fight.Switch(hit_data, state); 132 | if(state) 133 | move.OtherState(state); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /BlenderRigForUnity/F-curves Saver/BasicHuma.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import mathutils as m 3 | import math 4 | import pickle 5 | 6 | 7 | class Humanoid(): 8 | 9 | def __init__(self, armature, load = False, path = ''): 10 | 11 | self.path = path 12 | 13 | self.armature = armature 14 | self.footL = self.armature.pose.bones['Foot Control L'] 15 | self.footR = self.armature.pose.bones['Foot Control R'] 16 | self.handL = self.armature.pose.bones['IK Arm L'] 17 | self.handR = self.armature.pose.bones['IK Arm R'] 18 | self.head = self.armature.pose.bones['Head'] 19 | self.pelvis = self.armature.pose.bones['Pelvis'] 20 | self.spine1 = self.armature.pose.bones['Spine1'] 21 | self.spine2 = self.armature.pose.bones['Spine2'] 22 | 23 | self.legL = self.armature.pose.bones['Leg L'] 24 | self.legR = self.armature.pose.bones['Leg R'] 25 | 26 | self.shouL = self.armature.pose.bones['Upperarm L'] 27 | self.shouR = self.armature.pose.bones['Upperarm R'] 28 | 29 | self.targetArmL = self.armature.pose.bones['IKT Arm L'] 30 | self.targetArmR = self.armature.pose.bones['IKT Arm R'] 31 | 32 | self.targetLegL = self.armature.pose.bones['IKT Leg L'] 33 | self.targetLegR = self.armature.pose.bones['IKT Leg R'] 34 | 35 | self.bones = { 36 | 'footL':self.footL, 37 | 'footR':self.footR, 38 | 'armL':self.handL, 39 | 'armR':self.handR, 40 | 'pelvis':self.pelvis, 41 | 'spine1':self.spine1, 42 | 'spine2':self.spine2, 43 | 'head':self.head, 44 | 'targetLL':self.targetLegL, 45 | 'targetLR':self.targetLegR, 46 | 'targetAL':self.targetArmL, 47 | 'targetAR':self.targetArmR 48 | } 49 | 50 | leg_pos = self.armature.data.bones['Leg L'].head.z 51 | foot_pos = self.armature.data.bones['Foot Control L'].head.z 52 | hand_pos = self.armature.data.bones['Upperarm L'].head.x 53 | shoulder_pos = self.armature.data.bones['IK Arm L'].head.x 54 | 55 | # self.bones_names = [k.name for k in self.armature.data.bones] # PREVIOUS VERSION 56 | self.bones_names = [k.name for k in self.armature.data.bones if "other" not in k.name] 57 | 58 | self.arm_length = math.fabs(hand_pos - shoulder_pos) 59 | self.leg_length = math.fabs(leg_pos - foot_pos) 60 | 61 | self.initial_pelvis_pos = self.pelvis.head.x 62 | 63 | self.leg_sensitive = ['Foot Control L', 'Foot Control R','IKT Leg L','IKT Leg R', 'Pelvis'] 64 | self.arm_sensitive = ['IK Arm L','IK Arm R','IKT Arm L','IKT Arm R' ] 65 | 66 | def select(self, bone): 67 | 68 | bpy.ops.pose.select_all(action = 'DESELECT') 69 | self.armature.data.bones.active = self.armature.data.bones[bone.name] 70 | self.armature.data.bones[bone.name].select = True 71 | 72 | def select_index(self, nb): 73 | 74 | # Récuperer le nom de l'os. S'en servir pour le sélectionner. Je crois que c'est ce qui fait sauter le fait de plaquer les courbes. 75 | name = self.bones_names[nb] 76 | 77 | print('Selecting {}'.format(name)) 78 | bone = self.armature.pose.bones[name] 79 | self.select(bone) 80 | 81 | return name 82 | 83 | def get_curves(self): 84 | 85 | return self.armature.animation_data.action.fcurves 86 | 87 | def create_action(self, name): 88 | 89 | self.armature.animation_data_create() 90 | self.armature.animation_data.action = bpy.data.actions.new(name = name) 91 | -------------------------------------------------------------------------------- /QuickAnimation/BoneFollow.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import math 3 | import mathutils as m 4 | 5 | 6 | 7 | def select_bone_from_name(rig, name): 8 | 9 | bpy.ops.pose.select_all(action ='DESELECT') 10 | rig.data.bones.active = rig.data.bones[name] 11 | rig.data.bones[name].select = True 12 | 13 | def set_frame(nb): 14 | bpy.context.scene.frame_set(nb) 15 | print('Current frame is: {}'.format(bpy.context.scene.frame_current)) 16 | 17 | def add_kf_to_bone(rig, name): 18 | 19 | select_bone_from_name(rig, name) 20 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__', confirm_success = False) 21 | 22 | 23 | def follow_in_animation(rig, target_name, bone_name): 24 | 25 | rig = bpy.data.objects['Armature'] 26 | rig.pose.bones[bone_name].rotation_mode = rig.pose.bones[target_name].rotation_mode 27 | 28 | current_animation = rig.animation_data.action 29 | curves = current_animation.fcurves 30 | set_frame(0) 31 | bpy.ops.pose.select_all(action='SELECT') 32 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__', confirm_success = False) 33 | set_frame(int(current_animation.fcurves[0].keyframe_points[-1].co.x)) 34 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__', confirm_success = False) 35 | 36 | 37 | target_bone = rig.pose.bones[target_name] 38 | source_bone = rig.pose.bones[bone_name] 39 | 40 | 41 | for curve in curves: 42 | 43 | if(curve.group.name == target_name): 44 | 45 | for kf in curve.keyframe_points: 46 | 47 | set_frame(int(kf.co.x)) 48 | 49 | source_bone.matrix = target_bone.matrix 50 | select_bone_from_name(rig, bone_name) 51 | bpy.ops.anim.keyframe_insert_menu(type = '__ACTIVE__', confirm_success = False) 52 | break 53 | 54 | class DialogOperator(bpy.types.Operator): 55 | bl_idname = "object.dialog_operator" 56 | bl_label = "Bone follow" 57 | 58 | armature_name = bpy.props.StringProperty(name = "Armature name ?") 59 | bone_name = bpy.props.StringProperty(name="Following bone") 60 | bone_target_name = bpy.props.StringProperty(name="Bone to follow") 61 | all_anims = bpy.props.BoolProperty(name="All animations ?") 62 | # path_to_anim += "/home/mehdi/Blender/Scripts/" 63 | 64 | def execute(self, context): 65 | 66 | if self.all_anims: 67 | self.launch_follow_all() 68 | else: 69 | self.launch_follow() 70 | 71 | message = 'Finished following {} by {}'.format(self.bone_target_name, self.bone_name) 72 | self.report({'INFO'}, message) 73 | 74 | return {'FINISHED'} 75 | 76 | def invoke(self, context, event): 77 | wm = context.window_manager 78 | return wm.invoke_props_dialog(self) 79 | 80 | def launch_follow_all(self): 81 | 82 | all_actions = bpy.data.actions 83 | rig = bpy.data.objects[self.armature_name] 84 | for action in all_actions: 85 | 86 | rig.animation_data.action = action 87 | follow_in_animation(rig, self.bone_target_name, self.bone_name) 88 | 89 | 90 | def launch_follow(self): 91 | 92 | rig = bpy.data.objects[self.armature_name] 93 | follow_in_animation(rig,self.bone_target_name, self.bone_name) 94 | 95 | 96 | bpy.utils.register_class(DialogOperator) 97 | 98 | # test call 99 | bpy.ops.object.dialog_operator('INVOKE_DEFAULT', armature_name = 'Armature') 100 | 101 | -------------------------------------------------------------------------------- /GlobalBaseScripts/BaseFight.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BaseFight : MonoBehaviour { 6 | 7 | [Header("\t\t Hitboxes")] 8 | public BaseBoxes [] hitboxes; 9 | 10 | Dictionary HitDict; 11 | Dictionary ImpactDict; 12 | 13 | public bool is_hitting; 14 | 15 | Animator anim; 16 | Rigidbody rb; 17 | 18 | // Use this for initialization 19 | void Start () { 20 | 21 | Initialization(); 22 | 23 | } 24 | 25 | // Update is called once per frame 26 | void Update () { 27 | 28 | } 29 | 30 | public void Hit() 31 | { 32 | anim.SetTrigger("Hit"); 33 | } 34 | 35 | public void HoldThrow(bool state) 36 | { 37 | anim.SetBool("HoldThrow", state); 38 | } 39 | 40 | public void UpperCoordination(bool state) 41 | { 42 | float layer_weight = state ? 1f : 0f; 43 | anim.SetLayerWeight(1, layer_weight); 44 | } 45 | 46 | void FillDicts() 47 | { 48 | HitDict = new Dictionary(); 49 | ImpactDict = new Dictionary(); 50 | foreach(BaseBoxes hit in hitboxes) 51 | { 52 | if(hit.box.TypeImpact == 0) 53 | { 54 | ImpactDict.Add(hit.name, hit.box); 55 | } 56 | else if(hit.box.TypeImpact == 1) 57 | { 58 | HitDict.Add(hit.name, hit.box); 59 | } 60 | } 61 | } 62 | 63 | public void Switch(BaseHitData hit_data, bool state) 64 | { 65 | HitDict[hit_data.BoxName].Switch(hit_data, state); 66 | if(state) 67 | { 68 | ApplyHitImpulsion(hit_data); 69 | is_hitting = true; 70 | } 71 | else 72 | { 73 | is_hitting = false; 74 | } 75 | } 76 | 77 | public void ApplyHitImpulsion(BaseHitData hd) 78 | { 79 | rb.velocity += transform.forward*hd.ImpulsionStrength; 80 | } 81 | 82 | public void Impacted(Transform ennemy_transform, BaseHitData impact_hit_data) 83 | { 84 | // Vector3 direction = Vector3.ProjectOnPlane(transform.position - pos, Vector3.up).normalized; 85 | Vector3 direction_parameters = impact_hit_data.DirectionComponents; 86 | 87 | Vector3 direction = ennemy_transform.forward*direction_parameters.z + 88 | ennemy_transform.up*direction_parameters.y + 89 | ennemy_transform.right*direction_parameters.x; 90 | 91 | rb.velocity += direction.normalized*impact_hit_data.ImpactForce; 92 | 93 | 94 | anim.SetTrigger(impact_hit_data.ImpactTriggerName); 95 | } 96 | 97 | void Initialization() 98 | { 99 | anim = GetComponent(); 100 | rb = GetComponent(); 101 | 102 | is_hitting = false; 103 | 104 | FillDicts(); 105 | } 106 | 107 | 108 | } 109 | 110 | [System.Serializable] 111 | public struct BaseBoxes 112 | { 113 | public string name; 114 | public BaseHitImpact box; 115 | } 116 | 117 | [System.Serializable] 118 | public struct BaseHitData 119 | { 120 | public string BoxName; 121 | public float ImpulsionStrength; 122 | public float ImpactForce; 123 | public Vector3 DirectionComponents; 124 | public string ImpactTriggerName; 125 | 126 | public string ToString() 127 | { 128 | return "Hit impact " + BoxName + " Impulsion: " + ImpulsionStrength.ToString() + " ImpactStrength: " + ImpactForce.ToString(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /BoxingGame/BoxerMoveController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public class BoxerMoveController : MonoBehaviour { 7 | 8 | // public Text debug_text; 9 | 10 | public Transform Ennemy; 11 | public float Speed = 1f; 12 | public float RotatingSpeed = 1f; 13 | public float LerpAnimSpeed = 1f; 14 | 15 | Vector3 CurrentDirection = Vector3.zero; 16 | Vector3 DashDirection; 17 | Vector2 AnimDirection; 18 | Animator anim; 19 | Rigidbody rb; 20 | Camera cam; 21 | 22 | float height; 23 | 24 | // Use this for initialization 25 | void Start () { 26 | 27 | Initialization(); 28 | } 29 | 30 | // Update is called once per frame 31 | void Update () { 32 | 33 | 34 | RotateTowardsEnnemy(); 35 | AdjustAnim(); 36 | 37 | // DebugVision(); 38 | 39 | } 40 | 41 | 42 | // void DebugVision() 43 | // { 44 | // Vector2 d = GetComponent().GetDirection(); 45 | // Vector3 d_adapted = CamToPlayer(d); 46 | // float angle = Mathf.Deg2Rad*Vector3.SignedAngle(transform.forward, d_adapted, transform.up); 47 | 48 | // float x_angle = Mathf.Cos(angle); 49 | // float y_angle = Mathf.Sin(angle); 50 | 51 | // Debug.DrawRay(transform.position + transform.up, 5*d_adapted, Color.red, 1f); 52 | // Vector3 anim_vec = Quaternion.AngleAxis(angle, transform.up)*transform.forward; 53 | // string s = "Angle with character: " + angle.ToString(); 54 | // s += "\nFrom angle - X" + x_angle.ToString() +" Y " +y_angle.ToString(); 55 | // s += "\nAnimDirection " + AnimDirection.ToString(); 56 | 57 | // debug_text.text = s; 58 | // } 59 | 60 | void RotateTowardsEnnemy() 61 | { 62 | Vector3 to_ennemy = Vector3.ProjectOnPlane(Ennemy.position - transform.position, Vector3.up); 63 | Quaternion ideal_rotation = Quaternion.LookRotation(to_ennemy, Vector3.up); 64 | transform.rotation = Quaternion.Slerp(transform.rotation, ideal_rotation, RotatingSpeed*Time.deltaTime); 65 | } 66 | 67 | public void PlayerMove(Vector2 direction, bool dash) 68 | { 69 | if(dash) 70 | { 71 | DashDirection = direction.magnitude > 0.2f ? CamToPlayer(direction) : transform.forward; 72 | float angle = Mathf.Deg2Rad*Vector3.SignedAngle(transform.forward, DashDirection, Vector3.up); 73 | AnimDirection = new Vector3(Mathf.Sin(angle), Mathf.Cos(angle)); 74 | Dash(); 75 | } 76 | } 77 | 78 | void AdjustAnim() 79 | { 80 | Vector2 anim_xy = new Vector2(anim.GetFloat("X"), anim.GetFloat("Y")); 81 | anim_xy = Vector2.Lerp(anim_xy, AnimDirection, LerpAnimSpeed*Time.deltaTime); 82 | 83 | anim.SetFloat("X", anim_xy.x); 84 | anim.SetFloat("Y", anim_xy.y); 85 | } 86 | 87 | public void ApplyDashForce() 88 | { 89 | rb.velocity += DashDirection*Speed; 90 | } 91 | 92 | Vector3 CamToPlayer(Vector2 direction) 93 | { 94 | Vector3 forward = Vector3.ProjectOnPlane(transform.position - cam.transform.position, Vector3.up); 95 | Vector3 right = Quaternion.AngleAxis(90, Vector3.up)*forward; 96 | 97 | return (forward*direction.y + right*direction.x).normalized; 98 | } 99 | 100 | void Dash() 101 | { 102 | anim.SetTrigger("Dash"); 103 | } 104 | 105 | void Initialization() 106 | { 107 | cam = Camera.main; 108 | rb = GetComponent(); 109 | anim = GetComponent(); 110 | 111 | 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Controller/ControlCharacter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ControlCharacter : MonoBehaviour { 6 | 7 | public PersoFiller Filler; 8 | Perso me; 9 | 10 | public float JumpDelay = 0.1f; 11 | public bool UseDebug = false; 12 | 13 | // public GameObject Armature; 14 | 15 | // Quaternion InitalRotation; 16 | // float ArmatureAngle; 17 | 18 | // public Vector3 Obj; 19 | // public Vector3 Obj2; 20 | // public float LerpSpeed; 21 | // Use this for initialization 22 | public float hitDistance = 1f; 23 | void Start () { 24 | 25 | me = new Perso(gameObject, Filler, Camera.main); 26 | // InitalRotation = Armature.transform.localRotation; 27 | 28 | } 29 | 30 | // Update is called once per frame 31 | void Update () { 32 | 33 | me.MAJ(); 34 | 35 | float x = Input.GetAxis("Horizontal"); 36 | float y = Input.GetAxis("Vertical"); 37 | 38 | // float x = Input.GetAxis("HorKey"); 39 | // float y = Input.GetAxis("VerKey"); 40 | 41 | Vector3 RunningDirection = new Vector3(x,0,y); 42 | if(RunningDirection.magnitude > 0.2f) 43 | { 44 | me.Activate("Run"); 45 | me.PlayerMove(new Vector3(x,0,y)); 46 | // CheckPivot(RunningDirection); 47 | // RotateAroundY(RunningDirection); 48 | } 49 | 50 | if(Input.GetButtonDown("AButton")) 51 | { 52 | me.Activate("Jump"); 53 | me.Jump(JumpDelay); 54 | } 55 | 56 | if(Input.GetButtonDown("XButton")) 57 | { 58 | me.Activate("FootShoot"); 59 | } 60 | 61 | // if(Input.GetButtonDown("YButton")) 62 | // { 63 | // me.Activate("JumpOver"); 64 | // } 65 | 66 | 67 | // DebugFunctions(); 68 | // LerpRotation(); 69 | 70 | // CheckJumpOver(); 71 | } 72 | 73 | void CheckJumpOver() 74 | { 75 | Ray ray = new Ray(transform.position, transform.forward); 76 | RaycastHit hit; 77 | 78 | Debug.DrawRay(ray.origin, ray.direction*hitDistance, Color.red ,1); 79 | 80 | if(Physics.Raycast(ray, out hit, hitDistance)) 81 | { 82 | if(!me.GetGrounded()) 83 | { 84 | me.Activate("JumpOver"); 85 | me.CustomImpulsion(0.1f*transform.forward+transform.up, 10.5f, 0.0f,0.1f); 86 | } 87 | } 88 | } 89 | 90 | // void LerpRotation() 91 | // { 92 | // if(Input.GetButton("YButton")) 93 | // { 94 | // Armature.transform.localRotation = Quaternion.RotateTowards(Armature.transform.localRotation, Quaternion.Euler(Obj), 5); 95 | // } 96 | // else if(Input.GetButton("BButton")) 97 | // { 98 | // Armature.transform.localRotation = Quaternion.RotateTowards(Armature.transform.localRotation, Quaternion.Euler(Obj2), 5); 99 | // } 100 | // else 101 | // { 102 | // Armature.transform.localRotation = Quaternion.RotateTowards(Armature.transform.localRotation, InitalRotation, LerpSpeed); 103 | // } 104 | // } 105 | 106 | // void RotateAroundY(Vector3 v) 107 | // { 108 | // v = me.CamToPlayer(v); 109 | // float angle = Vector3.Angle(transform.forward, v); 110 | // if(angle > 15) 111 | // { 112 | // angle = (Vector3.Dot(transform.right, v) > 0) ? 1 : -1; 113 | // ArmatureAngle += angle*Time.deltaTime*TiltAngle; 114 | 115 | 116 | // Quaternion target = Quaternion.AngleAxis(25*angle, transform.forward); 117 | 118 | // Armature.transform.localRotation = Quaternion.RotateTowards(Armature.transform.rotation, target, 5); 119 | // } 120 | // // transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, step); !!!!!!! 121 | // Armature.transform.localRotation = Quaternion.Lerp(Armature.transform.localRotation, InitalRotation, Time.deltaTime); 122 | // // J'ESSAIE DE RAJOUTER LEANING SUIVANT LA COURSE ! A FINIR ! 123 | // } 124 | 125 | void DebugFunctions() 126 | { 127 | if(UseDebug) 128 | { 129 | UseDebug = false; 130 | me = new Perso(gameObject, Filler, Camera.main); 131 | } 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /ModularController/MoveModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class MoveModule : MonoBehaviour { 6 | 7 | 8 | public float Speed = 1f; 9 | public float RotatingSpeed = 1f; 10 | public float JumpForce = 1f; 11 | public float AdditionalGravity = 3f; 12 | 13 | [Space(10)] 14 | [Header("MinStepMax")] 15 | public float MaxSpeed = 15f; 16 | public Vector3 LerpDragSpeed; 17 | 18 | [Space(10)] 19 | [Header("Dash parameters")] 20 | public float DashForce = 1f; 21 | 22 | 23 | Vector3 CurrentDirection = Vector3.zero; 24 | 25 | Animator anim; 26 | Rigidbody rb; 27 | Camera cam; 28 | 29 | Quaternion initial_rotation; 30 | Quaternion other_rotation; 31 | Quaternion target; 32 | 33 | [HideInInspector] public bool is_jumping; 34 | 35 | float height; 36 | 37 | // Use this for initialization 38 | void Start () { 39 | 40 | Initialization(); 41 | 42 | } 43 | 44 | // Update is called once per frame 45 | void Update () { 46 | 47 | AdjustPhysics(); 48 | AdjustRotation(); 49 | AdjustAnim(); 50 | 51 | 52 | 53 | } 54 | 55 | public void PlayerMove(Vector2 direction) 56 | { 57 | CurrentDirection = direction; 58 | if(direction.magnitude > 0.1f) 59 | { 60 | Move(cam.transform.right*direction.x); 61 | Rotate(cam.transform.right*direction.x); 62 | } 63 | } 64 | 65 | public void Dash() 66 | { 67 | anim.SetTrigger("Dash"); 68 | } 69 | 70 | public void DashMove() 71 | { 72 | rb.velocity += transform.forward*DashForce; 73 | } 74 | 75 | void Move(Vector3 direction) 76 | { 77 | rb.AddForce(direction*Speed); 78 | } 79 | 80 | void Rotate(Vector3 direction) 81 | { 82 | target = (Vector3.Dot(direction, cam.transform.right) > 0) ? initial_rotation : other_rotation; 83 | } 84 | 85 | void AdjustRotation() 86 | { 87 | transform.rotation = Quaternion.Lerp(transform.rotation, target, RotatingSpeed*Time.deltaTime); 88 | } 89 | 90 | void AdjustAnim() 91 | { 92 | float speed_param = anim.GetFloat("Speed"); 93 | speed_param = Mathf.Clamp01(Mathf.Lerp(speed_param, rb.velocity.magnitude, LerpDragSpeed.y)); 94 | anim.SetFloat("Speed", speed_param); 95 | } 96 | 97 | void AdjustPhysics() 98 | { 99 | Ray ray = new Ray(transform.position, -Vector3.up); 100 | RaycastHit hit; 101 | 102 | if(Physics.Raycast(ray, out hit, height*1.05f)) 103 | { 104 | if(is_jumping) 105 | { 106 | anim.SetTrigger("Land"); 107 | } 108 | is_jumping = false; 109 | } 110 | else 111 | { 112 | if(!is_jumping) 113 | { 114 | anim.SetTrigger("Fall"); 115 | } 116 | is_jumping = true; 117 | } 118 | 119 | 120 | if(is_jumping) 121 | { 122 | rb.velocity += -Vector3.up*AdditionalGravity; 123 | LerpDrag(LerpDragSpeed.x); 124 | } 125 | else 126 | { 127 | if(CurrentDirection.magnitude > 0.2f) 128 | LerpDrag(LerpDragSpeed.x); 129 | else 130 | LerpDrag(LerpDragSpeed.z); 131 | } 132 | 133 | // CheckMaxSpeed(); 134 | } 135 | 136 | void LerpDrag(float v) 137 | { 138 | rb.drag = Mathf.Lerp(rb.drag, v, LerpDragSpeed.z*Time.deltaTime); 139 | } 140 | 141 | void CheckMaxSpeed() 142 | { 143 | float current_limit = is_jumping ? MaxSpeed*5f : MaxSpeed; 144 | // Debug.Log(current_limit); 145 | if(rb.velocity.magnitude > MaxSpeed) 146 | { 147 | Debug.Log("Speed over " + current_limit.ToString()); 148 | } 149 | Vector3 current_velocity = rb.velocity; 150 | current_velocity = (current_velocity.magnitude > current_limit) ? 151 | Vector3.Lerp(current_velocity, current_velocity.normalized*current_limit, LerpDragSpeed.y*Time.deltaTime) : current_velocity; 152 | rb.velocity = current_velocity; 153 | } 154 | 155 | 156 | 157 | void Initialization() 158 | { 159 | cam = Camera.main; 160 | rb = GetComponent(); 161 | anim = GetComponent(); 162 | 163 | initial_rotation = transform.rotation; 164 | other_rotation = Quaternion.AngleAxis(180, Vector3.up); 165 | target = initial_rotation; 166 | 167 | height = GetComponent().bounds.size.y/2f; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /AnthemController/NamedEffect.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class NamedEffect 7 | { 8 | public List Particles = new List(); 9 | public List Trails = new List(); 10 | 11 | [Header("Common Parameters")] 12 | public Transform DesiredSpot; 13 | // public float TimeBeforeDestruction = 0.5f; 14 | public string Name = "Effect"; 15 | public List Correspondance = new List(); 16 | 17 | [Header("Particles Parameters")] 18 | public bool Passive = false; 19 | public bool CreateInstance = true; 20 | public bool OnExit = false; 21 | 22 | [Header("Trail Parameters")] 23 | public float MinVelocity = 0.5f; 24 | 25 | [HideInInspector] 26 | public bool Active = false; 27 | 28 | 29 | bool Loaded = false; 30 | bool ready = false; 31 | bool trail_active = false; 32 | int nb_particles = 0; 33 | int nb_trails = 0; 34 | float CurrentSpeed = 0f; 35 | string current_anim = ""; 36 | 37 | 38 | public NamedEffect() 39 | { 40 | 41 | } 42 | 43 | public NamedEffect(List p, List t, string n, List c) 44 | { 45 | Particles = p; 46 | // Trails = t; 47 | Name = n; 48 | Correspondance = c; 49 | } 50 | 51 | void Init() 52 | { 53 | ready = true; 54 | nb_particles = Particles.Count; 55 | nb_trails = Trails.Count; 56 | } 57 | 58 | // while it is possible to add a delay to activate, it is also possible to add a delay to the effect ! 59 | 60 | public void Analyze(string c, float current_speed = 0f) 61 | { 62 | if(!ready) 63 | { 64 | Init(); 65 | } 66 | // In case needed by trail 67 | CurrentSpeed = current_speed; 68 | 69 | if(Correspondance.Contains(c)) 70 | { 71 | if(c != current_anim) 72 | { 73 | current_anim = c; 74 | Active = false; 75 | } 76 | if(!Active) 77 | { 78 | if(OnExit) 79 | SwitchExit(true); 80 | else 81 | Switch(true); 82 | } 83 | } 84 | else 85 | { 86 | if(OnExit) 87 | { 88 | SwitchExit(false); 89 | } 90 | else 91 | { 92 | Switch(false); 93 | } 94 | } 95 | } 96 | 97 | void SwitchExit(bool state) 98 | { 99 | if(state) 100 | { 101 | Active = true; 102 | Loaded = true; 103 | } 104 | else 105 | { 106 | if(Loaded) 107 | { 108 | Loaded = !Loaded; 109 | PlayAllParticles(); 110 | Active = false; 111 | } 112 | } 113 | 114 | } 115 | 116 | void Switch(bool state) 117 | { 118 | 119 | Active = state; 120 | if(Active) 121 | { 122 | if(nb_particles > 0) 123 | { 124 | PlayAllParticles(); 125 | } 126 | if(nb_trails > 0 && !trail_active && CurrentSpeed > MinVelocity) 127 | { 128 | ActivateAllTails(); 129 | } 130 | } 131 | else 132 | { 133 | if(nb_particles > 0) 134 | { 135 | StopAllParticles(); 136 | } 137 | if(nb_trails > 0 && trail_active) 138 | { 139 | StopAllTrails(); 140 | } 141 | } 142 | } 143 | 144 | void ActivateAllTails() 145 | { 146 | foreach(TrailRenderer t in Trails) 147 | { 148 | t.enabled = true; 149 | } 150 | trail_active = true; 151 | } 152 | 153 | void StopAllTrails() 154 | { 155 | foreach(TrailRenderer t in Trails) 156 | { 157 | t.enabled = false; 158 | } 159 | trail_active = false; 160 | } 161 | void PlayAllParticles() 162 | { 163 | if(CreateInstance) 164 | { 165 | foreach(ParticleSystem p in Particles) 166 | { 167 | ParticleSystem p_clone = Object.Instantiate(p, DesiredSpot.position, DesiredSpot.rotation); 168 | p_clone.GetComponent().enabled = true; 169 | // Object.Destroy(p_clone, TimeBeforeDestruction); 170 | p_clone.Play(); 171 | 172 | } 173 | } 174 | else 175 | { 176 | foreach(ParticleSystem p in Particles) 177 | { 178 | p.Play(); 179 | } 180 | } 181 | } 182 | 183 | void StopAllParticles() 184 | { 185 | if(!CreateInstance) 186 | { 187 | foreach(ParticleSystem p in Particles) 188 | { 189 | p.Stop(); 190 | } 191 | } 192 | 193 | } 194 | 195 | } -------------------------------------------------------------------------------- /GhostOfTsushimaController/NamedEffect.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [System.Serializable] 6 | public class NamedEffect 7 | { 8 | public List Particles = new List(); 9 | public List Trails = new List(); 10 | 11 | [Header("Common Parameters")] 12 | public Transform DesiredSpot; 13 | // public float TimeBeforeDestruction = 0.5f; 14 | public string Name = "Effect"; 15 | public List Correspondance = new List(); 16 | 17 | [Header("Particles Parameters")] 18 | public bool Passive = false; 19 | public bool CreateInstance = true; 20 | public bool OnExit = false; 21 | 22 | [Header("Trail Parameters")] 23 | public float MinVelocity = 0.5f; 24 | 25 | [HideInInspector] 26 | public bool Active = false; 27 | 28 | 29 | bool Loaded = false; 30 | bool ready = false; 31 | bool trail_active = false; 32 | int nb_particles = 0; 33 | int nb_trails = 0; 34 | float CurrentSpeed = 0f; 35 | string current_anim = ""; 36 | 37 | 38 | public NamedEffect() 39 | { 40 | 41 | } 42 | 43 | public NamedEffect(List p, List t, string n, List c) 44 | { 45 | Particles = p; 46 | // Trails = t; 47 | Name = n; 48 | Correspondance = c; 49 | } 50 | 51 | void Init() 52 | { 53 | ready = true; 54 | nb_particles = Particles.Count; 55 | nb_trails = Trails.Count; 56 | } 57 | 58 | // while it is possible to add a delay to activate, it is also possible to add a delay to the effect ! 59 | 60 | public void Analyze(string c, float current_speed = 0f) 61 | { 62 | if(!ready) 63 | { 64 | Init(); 65 | } 66 | // In case needed by trail 67 | CurrentSpeed = current_speed; 68 | 69 | if(Correspondance.Contains(c)) 70 | { 71 | if(c != current_anim) 72 | { 73 | current_anim = c; 74 | Active = false; 75 | } 76 | if(!Active) 77 | { 78 | if(OnExit) 79 | SwitchExit(true); 80 | else 81 | Switch(true); 82 | } 83 | } 84 | else 85 | { 86 | if(OnExit) 87 | { 88 | SwitchExit(false); 89 | } 90 | else 91 | { 92 | Switch(false); 93 | } 94 | } 95 | } 96 | 97 | void SwitchExit(bool state) 98 | { 99 | if(state) 100 | { 101 | Active = true; 102 | Loaded = true; 103 | } 104 | else 105 | { 106 | if(Loaded) 107 | { 108 | Loaded = !Loaded; 109 | PlayAllParticles(); 110 | Active = false; 111 | } 112 | } 113 | 114 | } 115 | 116 | void Switch(bool state) 117 | { 118 | 119 | Active = state; 120 | if(Active) 121 | { 122 | if(nb_particles > 0) 123 | { 124 | PlayAllParticles(); 125 | } 126 | if(nb_trails > 0 && !trail_active && CurrentSpeed > MinVelocity) 127 | { 128 | ActivateAllTails(); 129 | } 130 | } 131 | else 132 | { 133 | if(nb_particles > 0) 134 | { 135 | StopAllParticles(); 136 | } 137 | if(nb_trails > 0 && trail_active) 138 | { 139 | StopAllTrails(); 140 | } 141 | } 142 | } 143 | 144 | void ActivateAllTails() 145 | { 146 | foreach(TrailRenderer t in Trails) 147 | { 148 | t.enabled = true; 149 | } 150 | trail_active = true; 151 | } 152 | 153 | void StopAllTrails() 154 | { 155 | foreach(TrailRenderer t in Trails) 156 | { 157 | t.enabled = false; 158 | } 159 | trail_active = false; 160 | } 161 | void PlayAllParticles() 162 | { 163 | if(CreateInstance) 164 | { 165 | foreach(ParticleSystem p in Particles) 166 | { 167 | ParticleSystem p_clone = Object.Instantiate(p, DesiredSpot.position, DesiredSpot.rotation); 168 | p_clone.GetComponent().enabled = true; 169 | // Object.Destroy(p_clone, TimeBeforeDestruction); 170 | p_clone.Play(); 171 | 172 | } 173 | } 174 | else 175 | { 176 | foreach(ParticleSystem p in Particles) 177 | { 178 | p.Play(); 179 | } 180 | } 181 | } 182 | 183 | void StopAllParticles() 184 | { 185 | if(!CreateInstance) 186 | { 187 | foreach(ParticleSystem p in Particles) 188 | { 189 | p.Stop(); 190 | } 191 | } 192 | 193 | } 194 | 195 | } -------------------------------------------------------------------------------- /SkatingGame/SkateControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public class SkateControl : MonoBehaviour { 7 | 8 | public Camera cam; 9 | public float Speed = 1f; 10 | public float RotatingSpeed = 1f; 11 | public float AdditionalGravity = 0.5f; 12 | public float LandingAccelerationRatio = 0.5f; 13 | 14 | 15 | public bool reverse = false; 16 | 17 | [HideInInspector] public Rigidbody rb; 18 | InputProcessing inputs; 19 | SkateAnim anim; 20 | float height; 21 | 22 | public bool aerial; 23 | 24 | [HideInInspector] public Quaternion PhysicsRotation; 25 | [HideInInspector] public Quaternion VelocityRotation; 26 | [HideInInspector] public Quaternion InputRotation; 27 | [HideInInspector] public Quaternion ComputedRotation; 28 | 29 | // Use this for initialization 30 | void Start () { 31 | 32 | Initialization(); 33 | 34 | } 35 | 36 | // Update is called once per frame 37 | void Update () { 38 | CheckPhysics(); 39 | 40 | Vector2 direction = inputs.GetDirection(); 41 | SkaterMove(direction); 42 | 43 | } 44 | 45 | 46 | void CheckPhysics() 47 | { 48 | Ray ray = new Ray(transform.position, -transform.up); 49 | RaycastHit hit; 50 | 51 | if(Physics.Raycast(ray, out hit, 1.05f*height)) 52 | { 53 | if(aerial) 54 | { 55 | VelocityOnLanding(); 56 | } 57 | aerial = false; 58 | } 59 | else 60 | { 61 | aerial = true; 62 | rb.velocity += Vector3.down*AdditionalGravity; 63 | } 64 | 65 | } 66 | 67 | void VelocityOnLanding() 68 | { 69 | float magn_vel = rb.velocity.magnitude; 70 | Vector3 new_vel = rb.velocity; 71 | new_vel.y = 0; 72 | new_vel = new_vel.normalized*magn_vel; 73 | 74 | rb.velocity += LandingAccelerationRatio*new_vel; 75 | 76 | } 77 | 78 | 79 | void SkaterMove(Vector2 inputs) 80 | { 81 | 82 | PhysicsRotation = aerial ? Quaternion.identity : GetPhysicsRotation(); // Rotation according to ground normal 83 | VelocityRotation = GetVelocityRot(); 84 | InputRotation = Quaternion.identity; 85 | ComputedRotation = Quaternion.identity; 86 | 87 | 88 | if(inputs.magnitude > 0.1f) 89 | { 90 | Vector3 adapted_direction = CamToPlayer(inputs); 91 | Vector3 planar_direction = transform.forward; 92 | planar_direction.y = 0; 93 | InputRotation = Quaternion.FromToRotation(planar_direction, adapted_direction); 94 | 95 | if(!aerial) 96 | { 97 | Vector3 Direction = InputRotation*transform.forward*Speed; 98 | rb.AddForce(Direction); 99 | } 100 | } 101 | 102 | ComputedRotation = PhysicsRotation*VelocityRotation*transform.rotation; 103 | transform.rotation = Quaternion.Lerp(transform.rotation, ComputedRotation, RotatingSpeed*Time.deltaTime); 104 | } 105 | 106 | 107 | Quaternion GetVelocityRot() 108 | { 109 | Vector3 vel = rb.velocity; 110 | if(vel.magnitude > 0.2f) 111 | { 112 | vel.y = 0; 113 | Vector3 dir = transform.forward; 114 | dir.y = 0; 115 | Quaternion vel_rot = Quaternion.FromToRotation(dir.normalized, vel.normalized); 116 | return vel_rot; 117 | } 118 | else 119 | return Quaternion.identity; 120 | } 121 | 122 | Quaternion GetPhysicsRotation() 123 | { 124 | Vector3 target_vec = Vector3.up; 125 | Ray ray = new Ray(transform.position, Vector3.down); 126 | RaycastHit hit; 127 | 128 | if(Physics.Raycast(ray, out hit, 1.05f*height)) 129 | { 130 | target_vec = hit.normal; 131 | } 132 | 133 | return Quaternion.FromToRotation(transform.up, target_vec); 134 | } 135 | 136 | Vector3 CamToPlayer(Vector2 d) 137 | { 138 | Vector3 cam_to_player = transform.position - cam.transform.position; 139 | cam_to_player.y = 0; 140 | 141 | Vector3 cam_to_player_right = Quaternion.AngleAxis(90, Vector3.up)*cam_to_player; 142 | 143 | Vector3 direction = cam_to_player*d.y + cam_to_player_right*d.x; 144 | return direction.normalized; 145 | } 146 | 147 | void Initialization() 148 | { 149 | // cam = Camera.main; 150 | // TargetRotation = transform.rotation; 151 | // VelocityRotation = Quaternion.identity; 152 | rb = GetComponent(); 153 | inputs = GetComponent() ; 154 | anim = GetComponent(); 155 | height = GetComponent().bounds.size.y/2f; 156 | } 157 | } -------------------------------------------------------------------------------- /BoxingGame/AIProto3.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public class AIProto3 : MonoBehaviour { 7 | 8 | 9 | public Text debug_text; 10 | 11 | public NamedDistance [] distances; 12 | public AIState [] states; 13 | 14 | public Transform Target; 15 | public AITimer think_timer; 16 | 17 | BoxerModularController controller; 18 | Dictionary distance_to_action; 19 | 20 | // Use this for initialization 21 | void Start () { 22 | 23 | controller = GetComponent(); 24 | NormalizeActions(); 25 | FillDict(); 26 | } 27 | 28 | // Update is called once per frame 29 | void Update () { 30 | 31 | think_timer.timer -= Time.deltaTime; 32 | if(think_timer.timer <= 0) 33 | { 34 | think_timer.timer = think_timer.CoolDown; 35 | string result = Logic(); 36 | ParseLogic(result); 37 | } 38 | 39 | 40 | 41 | } 42 | 43 | void ParseLogic(string result) 44 | { 45 | if(result =="fight") 46 | { 47 | controller.IAOrder(RandomizeCommand(true)); 48 | } 49 | else 50 | { 51 | controller.IAOrder(RandomizeCommand(false)); 52 | } 53 | } 54 | 55 | string Logic() 56 | { 57 | 58 | string debug_recap = ""; 59 | float current_distance = (transform.position - Target.transform.position).magnitude; 60 | string current_distance_name = ""; 61 | 62 | 63 | debug_recap += "Real distance: " + current_distance.ToString(); 64 | foreach(NamedDistance d in distances) 65 | { 66 | if(current_distance < d.MaxDistance) 67 | { 68 | current_distance_name = d.Name; 69 | break; 70 | } 71 | } 72 | 73 | debug_recap += "\nDistance name: " + current_distance_name; 74 | 75 | AIState current_state = distance_to_action[current_distance_name]; 76 | float selector = Random.Range(0f,1f); 77 | string action_name = ""; 78 | debug_recap += "\nselector: " + selector.ToString(); 79 | foreach(AIActionAtom ac in current_state.actions) 80 | { 81 | if(selector < ac.Prob) 82 | { 83 | action_name = ac.Name; 84 | break; 85 | } 86 | } 87 | debug_recap += "\nAction: " + action_name; 88 | debug_text.text = debug_recap; 89 | 90 | return action_name; 91 | 92 | } 93 | 94 | Command RandomizeCommand(bool fight) 95 | { 96 | Command c; 97 | if(fight) 98 | { 99 | int side = Random.Range(0,2); 100 | int attack = Random.Range(0,4); 101 | c = new Command(Vector2.zero, false, side, attack); 102 | } 103 | else 104 | { 105 | Vector2 d = new Vector2(Random.Range(-1f,1f),Random.Range(-1f,1f)); 106 | c = new Command(d.normalized, true, 0, 0); 107 | } 108 | return c; 109 | } 110 | 111 | void NormalizeActions() 112 | { 113 | foreach(AIState s in states) 114 | { 115 | float sum_probs = 0f; 116 | for(int i = 0; i(); 134 | for(int i = 0; i