plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,104 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class changeGlobalGravityPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public LayerMask layer;
public bool changeGlobalGravityOnSecondaryPowerActive;
public bool changeGravityOnVehicles;
public bool changeGravityOnCharacter;
public bool pushNPCS;
[Space]
public string messageNameToSend = "pushCharacter";
public List<string> ignoreTagList = new List<string> ();
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public Transform mainCameraTransform;
public gravitySystem gravityManager;
List<vehicleGravityControl> vehicleGravityControlList = new List<vehicleGravityControl> ();
RaycastHit hit;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//change level's gravity
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger && hit.collider.gameObject.GetComponent<Rigidbody> () == null) {
powersManager.createShootParticles ();
Physics.gravity = -hit.normal * 9.8f;
}
}
}
public void activateSecondaryPower ()
{
if (!powerEnabled) {
return;
}
//change level's gravity
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger && hit.collider.gameObject.GetComponent<Rigidbody> () == null) {
powersManager.createShootParticles ();
if (changeGlobalGravityOnSecondaryPowerActive) {
Physics.gravity = -hit.normal * 9.8f;
}
if (changeGravityOnCharacter) {
gravityManager.changeGravityDirectionDirectly (hit.normal, true);
}
if (changeGravityOnVehicles) {
vehicleGravityControl[] vehicleGravityControlListFound = FindObjectsOfType (typeof(vehicleGravityControl)) as vehicleGravityControl[];
for (int i = 0; i < vehicleGravityControlListFound.Length; i++) {
vehicleGravityControlList.Add (vehicleGravityControlListFound [i]);
}
for (int i = 0; i < vehicleGravityControlList.Count; i++) {
vehicleGravityControlList [i].rotateVehicleToLandSurface (hit.normal);
}
}
if (pushNPCS) {
playerController[] playerControllerListFound = FindObjectsOfType (typeof(playerController)) as playerController[];
for (int i = 0; i < playerControllerListFound.Length; i++) {
GameObject objectToPush = playerControllerListFound [i].gameObject;
if (!ignoreTagList.Contains (objectToPush.tag)) {
objectToPush.SendMessage (messageNameToSend, hit.normal, SendMessageOptions.DontRequireReceiver);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a937352593fe11446834cbb4010b0981
timeCreated: 1537152207
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/changeGlobalGravityPower.cs
uploadId: 814740

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class changeObjectsPositionPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public LayerMask layer;
public LayerMask groundLayer;
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public Transform mainCameraTransform;
public Transform playerTransform;
public Transform playerCameraTransform;
public gravitySystem gravityManager;
RaycastHit hit;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//this power changes the player's position with the object located with a ray when the player fires
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger) {
powersManager.createShootParticles ();
GameObject objectToMove = hit.collider.gameObject;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (objectToMove);
if (characterDetected != null) {
objectToMove = characterDetected;
} else if (objectToMove.GetComponent<Rigidbody> () == null) {
return;
}
Vector3 newPlayerPosition = objectToMove.transform.position;
Vector3 newObjectPosition = playerTransform.position;
objectToMove.transform.position = Vector3.one * 100;
playerTransform.position = Vector3.zero;
if (Physics.Raycast (newPlayerPosition, -gravityManager.getCurrentNormal (), out hit, Mathf.Infinity, groundLayer)) {
newPlayerPosition = hit.point;
}
if (Physics.Raycast (newObjectPosition + playerTransform.up, -gravityManager.getCurrentNormal (), out hit, Mathf.Infinity, groundLayer)) {
newObjectPosition = hit.point + playerTransform.up;
}
objectToMove.transform.position = newObjectPosition;
playerTransform.position = newPlayerPosition;
playerCameraTransform.position = newPlayerPosition;
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 82139cad13caca347a23175270fa10a6
timeCreated: 1537152537
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/changeObjectsPositionPower.cs
uploadId: 814740

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class deviceToControlAtDistance : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool deviceToControlEnabled = true;
public GameObject deviceToControlGameObject;
public bool isDeviceToControlEnabled ()
{
return deviceToControlEnabled;
}
public GameObject getDeviceToControlGameObject ()
{
if (deviceToControlGameObject == null) {
deviceToControlGameObject = gameObject;
}
return deviceToControlGameObject;
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 672f04d04ccc59a4fb9c352b18cca641
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/deviceToControlAtDistance.cs
uploadId: 814740

View File

@@ -0,0 +1,345 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class joinObjectsPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public float joinObjectsForce = 40;
public float timeToRemoveJoin = 5;
public float extraForceOnVehicles = 1;
public bool useForceMode;
public ForceMode forceModeObject1;
public ForceMode forceModeObject2;
[Space]
[Header ("Debug")]
[Space]
public bool joinObjects;
public Transform joinObject1;
public Transform joinObject2;
public bool joinKinematic1;
public bool joinKinematic2;
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public LayerMask layer;
public Transform mainCameraTransform;
public GameObject impactParticles;
public GameObject playerGameObject;
GameObject joinParticles1;
GameObject joinParticles2;
Vector3 joinDirection1;
Vector3 joinDirection2;
Vector3 joinPosition1;
Vector3 joinPosition2;
RaycastHit hit;
checkCollisionType currentCheckCollisionType1;
checkCollisionType currentCheckCollisionType2;
public Rigidbody currentRigidbody1;
public Rigidbody currentRigidbody2;
Vector3 heading1;
Vector3 heading2;
ParticleSystem particles1;
ParticleSystem particles2;
bool currentRigidbody1IsVehicle;
bool currentRigidbody2IsVehicle;
float lastTimeJoined;
Coroutine updateCoroutine;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
//two objects are going to be attracted each other
if (joinObjects) {
if (Time.time > lastTimeJoined + timeToRemoveJoin) {
removeObjectsjoin ();
return;
}
//when both objects are stored, then it is checked if any of them have a rigidbody, to add force to them or not
//to this, it is used checkCollisionType, a script that allows to check any type of collision with collider or triggers and enter or exit
//and also can be configurated if the player want to check if the collision is with a particular object, in this case to both join object
//the collision to check is the opposite object
//once the script is added to every object, then the direction of the force to applied is calculated, and checking to which object can be applied
if (currentCheckCollisionType1 && currentCheckCollisionType2) {
//check if the player has not rigidbody, so the position to follow is the hit point
if (joinKinematic1) {
joinParticles2.transform.transform.LookAt (joinPosition1);
heading1 = joinObject2.position - joinPosition1;
} else {
//else, the position of the direction is the position of the object
//also a couple of particles are added
joinParticles2.transform.transform.LookAt (joinObject1.position);
heading1 = joinObject2.position - joinObject1.position;
}
joinDirection1 = heading1 / heading1.magnitude;
if (joinKinematic2) {
joinParticles1.transform.transform.LookAt (joinPosition2);
heading2 = joinObject1.position - joinPosition2;
} else {
joinParticles1.transform.transform.LookAt (joinObject2.position);
heading2 = joinObject1.position - joinObject2.position;
}
joinDirection2 = heading2 / heading2.magnitude;
if (!particles1) {
particles1 = joinParticles1.GetComponent<ParticleSystem> ();
}
if (particles1) {
var particles1Main = particles1.main;
particles1Main.startSpeed = GKC_Utils.distance (joinParticles1.transform.position, joinObject2.position) / 2;
}
if (!particles2) {
particles2 = joinParticles2.GetComponent<ParticleSystem> ();
}
if (particles2) {
var particles2Main = particles2.main;
particles2Main.startSpeed = GKC_Utils.distance (joinParticles2.transform.position, joinObject1.position) / 2;
}
//add force to the object, according to the direction of the other object
if (currentRigidbody1 && currentRigidbody2) {
addForce (-joinDirection2 * (joinObjectsForce * currentRigidbody1.mass), currentRigidbody1, forceModeObject1, currentRigidbody1IsVehicle);
addForce (-joinDirection1 * (joinObjectsForce * currentRigidbody2.mass), currentRigidbody2, forceModeObject2, currentRigidbody2IsVehicle);
} else if (currentRigidbody1 && !currentRigidbody2) {
addForce (-joinDirection2 * (joinObjectsForce * currentRigidbody1.mass), currentRigidbody1, forceModeObject1, currentRigidbody1IsVehicle);
} else if (!currentRigidbody1 && currentRigidbody2) {
addForce (-joinDirection1 * (joinObjectsForce * currentRigidbody2.mass), currentRigidbody2, forceModeObject2, currentRigidbody2IsVehicle);
} else {
//if both objects have not rigidbodies, then cancel the join
removeObjectsjoin ();
return;
}
//if the collision happens, the scripts are removed, and every object return to their normal situation
if (currentCheckCollisionType1.active || currentCheckCollisionType2.active) {
removeObjectsjoin ();
}
}
}
}
public void addForce (Vector3 direction, Rigidbody rigidbodyAffected, ForceMode forceModeToUsse, bool isVehicle)
{
if (isVehicle) {
direction *= extraForceOnVehicles;
}
if (useForceMode) {
rigidbodyAffected.AddForce (direction, forceModeToUsse);
} else {
rigidbodyAffected.AddForce (direction);
}
}
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//this power allows the player to join two objects, and add force to both in the position of the other, checking if any of the objects
//has rigidbody or not, and when both objects collide, the join is disabled
if (joinObject1 == null || joinObject2 == null) {
powersManager.createShootParticles ();
//get every object using a raycast
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.forward, out hit, Mathf.Infinity, layer)) {
if (joinObject1 == null) {
joinObject1 = hit.collider.transform;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (joinObject1.gameObject);
if (characterDetected != null) {
currentRigidbody1IsVehicle = applyDamage.isVehicle (characterDetected);
joinObject1 = characterDetected.transform;
}
if (!applyDamage.canApplyForce (joinObject1.gameObject)) {
joinKinematic1 = true;
joinPosition1 = hit.point;
}
joinParticles1 = (GameObject)Instantiate (impactParticles, hit.point, Quaternion.LookRotation (hit.normal));
joinParticles1.transform.SetParent (joinObject1);
joinParticles1.SetActive (true);
return;
}
if (joinObject2 == null && joinObject1 != hit.collider.transform && !hit.collider.transform.IsChildOf (joinObject1)) {
joinObject2 = hit.collider.transform;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (joinObject2.gameObject);
if (characterDetected != null) {
currentRigidbody2IsVehicle = applyDamage.isVehicle (characterDetected);
joinObject2 = characterDetected.transform;
}
if (!applyDamage.canApplyForce (joinObject2.gameObject)) {
joinKinematic2 = true;
joinPosition2 = hit.point;
}
joinParticles2 = (GameObject)Instantiate (impactParticles, hit.point, Quaternion.LookRotation (hit.normal));
joinParticles2.transform.SetParent (joinObject2);
joinParticles2.SetActive (true);
}
}
}
if (joinObject1 != null && joinObject2 != null) {
lastTimeJoined = Time.time;
joinObjects = true;
currentCheckCollisionType1 = joinObject1.GetComponent<checkCollisionType> ();
currentCheckCollisionType2 = joinObject2.GetComponent<checkCollisionType> ();
currentRigidbody1 = applyDamage.applyForce (joinObject1.gameObject);
currentRigidbody2 = applyDamage.applyForce (joinObject2.gameObject);
if (currentCheckCollisionType1 == null && currentCheckCollisionType2 == null) {
joinObject1.gameObject.AddComponent<checkCollisionType> ();
joinObject2.gameObject.AddComponent<checkCollisionType> ();
currentCheckCollisionType1 = joinObject1.GetComponent<checkCollisionType> ();
currentCheckCollisionType2 = joinObject2.GetComponent<checkCollisionType> ();
currentCheckCollisionType1.onCollisionEnter = true;
currentCheckCollisionType2.onCollisionEnter = true;
currentCheckCollisionType1.objectToCollide = joinObject2.gameObject;
currentCheckCollisionType2.objectToCollide = joinObject1.gameObject;
if (currentRigidbody1 != null) {
currentRigidbody1.useGravity = false;
}
if (currentRigidbody2 != null) {
currentRigidbody2.useGravity = false;
}
//a join object can be used to be launched to an enemy, hurting him, to check this, it is used launchedObjects
if (!joinKinematic1) {
joinObject1.gameObject.AddComponent<launchedObjects> ().setCurrentPlayer (playerGameObject);
}
if (!joinKinematic2) {
joinObject2.gameObject.AddComponent<launchedObjects> ().setCurrentPlayer (playerGameObject);
}
}
stopUpdateCoroutine ();
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
}
//if none of the objects join have rigidbody, the join is cancelled
public void removeObjectsjoin ()
{
if (currentCheckCollisionType1 != null) {
Destroy (currentCheckCollisionType1);
}
if (currentCheckCollisionType2 != null) {
Destroy (currentCheckCollisionType2);
}
launchedObjects currentLaunchedObjects1 = joinObject1.GetComponent<launchedObjects> ();
if (currentLaunchedObjects1 != null) {
Destroy (currentLaunchedObjects1);
}
launchedObjects currentLaunchedObjects2 = joinObject2.GetComponent<launchedObjects> ();
if (currentLaunchedObjects2 != null) {
Destroy (currentLaunchedObjects2);
}
if (currentRigidbody1 != null) {
currentRigidbody1.useGravity = true;
currentRigidbody1 = null;
}
if (currentRigidbody2 != null) {
currentRigidbody2.useGravity = true;
currentRigidbody2 = null;
}
stopUpdateCoroutine ();
joinObjects = false;
joinObject1 = null;
joinObject2 = null;
joinKinematic1 = false;
joinKinematic2 = false;
Destroy (joinParticles1);
Destroy (joinParticles2);
particles1 = null;
particles2 = null;
currentRigidbody1IsVehicle = false;
currentRigidbody2IsVehicle = false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fb5409083c769c041a0677eae2530713
timeCreated: 1537147373
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/joinObjectsPower.cs
uploadId: 814740

View File

@@ -0,0 +1,379 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pushObjectsPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public bool pushObjectsFromCenterPosition;
public bool pushObjectsFromPlayerForwardDirection;
public LayerMask layer;
public List<string> ignoreTagList = new List<string> ();
public bool useMessageToPushCharactersFound = true;
public string messageNameToSend = "pushCharacter";
[Space]
[Header ("Damage Settings")]
[Space]
public bool applyDamageOnFoundObjects;
public float damageToApply;
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Force Settings")]
[Space]
public float forceToApply = 4000;
public ForceMode forceMode;
public bool canApplyForceToVehicles = true;
public float applyForceToVehiclesMultiplier = 0.2f;
public bool applyForceToFoundObjectsOnlyOnce;
public bool checkRagdollsDetected;
public float ragdollMultiplierForce = 1;
[Space]
[Header ("Others Settings")]
[Space]
public bool useCustomPushCenterDistance;
public float pushCenterDistance;
public bool searchForObjectsOnUpdate;
public bool checkIfObjectInFrontOfPlayer;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameList = new List<string> ();
[Space]
public bool callRemoteEventsBeforeApplyingForce;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool useOfPowerPaused;
[Space]
public List<Rigidbody> vehiclesRigidbodyFoundList = new List<Rigidbody> ();
public List<GameObject> gameObjectsFoundList = new List<GameObject> ();
[Space]
[Header ("Components")]
[Space]
public playerWeaponSystem mainPlayerWeaponSystem;
public GameObject playerGameObject;
public Transform centerPosition;
public otherPowers powersManager;
public Transform pushObjectsCenter;
public Transform mainCameraTransform;
Rigidbody objectToDamageMainRigidbody;
GameObject objectToPush;
Collider [] colliders;
Vector3 currentForceToApply;
float finalExplosionForce;
bool isVehicle;
bool componentsInitialized;
void Start ()
{
if (!useCustomPushCenterDistance) {
//get the distance from the empty object in the player to push objects, close to it
pushCenterDistance = GKC_Utils.distance (playerGameObject.transform.position, pushObjectsCenter.position);
}
if (pushObjectsFromCenterPosition) {
if (centerPosition == null) {
centerPosition = transform;
}
}
}
void Update ()
{
if (searchForObjectsOnUpdate) {
activatePower ();
}
}
public void activatePower ()
{
if (useOfPowerPaused) {
return;
}
if (!powerEnabled) {
return;
}
initializeComponents ();
vehiclesRigidbodyFoundList.Clear ();
if (powersManager != null) {
//the power number 2 is push objects, so any bullet is created
powersManager.createShootParticles ();
}
//if the power selected is push objects, check the objects close to pushObjectsCenter and add force to them in camera forward direction
colliders = Physics.OverlapSphere (pushObjectsCenter.position, pushCenterDistance, layer);
for (int i = 0; i < colliders.Length; i++) {
if (!colliders [i].isTrigger) {
objectToPush = colliders [i].gameObject;
checkObjectToApplyForce (objectToPush);
}
}
}
public void checkObjectToApplyForce (GameObject currentObject)
{
if (applyForceToFoundObjectsOnlyOnce) {
if (!gameObjectsFoundList.Contains (currentObject)) {
gameObjectsFoundList.Add (currentObject);
} else {
return;
}
}
if (!ignoreTagList.Contains (currentObject.tag) && currentObject != playerGameObject) {
if (playerGameObject == null) {
playerGameObject = gameObject;
}
if (checkIfObjectInFrontOfPlayer) {
float dot = Vector3.Dot (playerGameObject.transform.forward, (currentObject.transform.position - playerGameObject.transform.position).normalized);
if (dot < 0) {
return;
}
}
Vector3 pushDirection = Vector3.zero;
if (pushObjectsFromCenterPosition) {
pushDirection = (currentObject.transform.position - centerPosition.position).normalized;
} else {
if (pushObjectsFromPlayerForwardDirection) {
pushDirection = playerGameObject.transform.forward;
} else {
if (mainCameraTransform != null) {
pushDirection = mainCameraTransform.forward;
}
}
}
if (useMessageToPushCharactersFound && messageNameToSend != "") {
currentObject.SendMessage (messageNameToSend, pushDirection, SendMessageOptions.DontRequireReceiver);
}
if (applyDamageOnFoundObjects) {
applyDamage.checkHealth (playerGameObject, currentObject, damageToApply, playerGameObject.transform.forward, transform.position, playerGameObject,
false, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
}
objectToDamageMainRigidbody = applyDamage.applyForce (currentObject);
if (showDebugPrint) {
print ("object detected rigidbody result " + currentObject.name + " " + (objectToDamageMainRigidbody != null));
}
bool rigidbodyFound = false;
if (canApplyForceToVehicles) {
if (objectToDamageMainRigidbody != null) {
if (!vehiclesRigidbodyFoundList.Contains (objectToDamageMainRigidbody)) {
if (callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (objectToDamageMainRigidbody.gameObject);
}
isVehicle = applyDamage.isVehicle (currentObject);
finalExplosionForce = forceToApply;
if (isVehicle) {
finalExplosionForce *= applyForceToVehiclesMultiplier;
}
if (pushObjectsFromCenterPosition) {
currentForceToApply = (objectToDamageMainRigidbody.position - centerPosition.position).normalized * finalExplosionForce;
} else {
if (pushObjectsFromPlayerForwardDirection) {
currentForceToApply = playerGameObject.transform.forward * finalExplosionForce;
} else {
currentForceToApply = mainCameraTransform.TransformDirection (Vector3.forward) * finalExplosionForce;
}
}
if (checkRagdollsDetected) {
if (applyDamage.isRagdollActive (currentObject)) {
// print ("ragdoll found");
currentForceToApply *= ragdollMultiplierForce;
} else {
// print ("Not found");
}
}
if (currentForceToApply != Vector3.zero) {
objectToDamageMainRigidbody.AddForce (currentForceToApply * objectToDamageMainRigidbody.mass, forceMode);
if (showDebugPrint) {
print ("object to apply force " + objectToDamageMainRigidbody.name + " " + currentForceToApply);
}
}
if (isVehicle) {
vehiclesRigidbodyFoundList.Add (objectToDamageMainRigidbody);
}
if (!callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (objectToDamageMainRigidbody.gameObject);
}
rigidbodyFound = true;
}
}
} else {
if (applyDamage.canApplyForce (currentObject)) {
if (callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (currentObject);
}
if (pushObjectsFromCenterPosition) {
currentForceToApply = (objectToDamageMainRigidbody.position - centerPosition.position).normalized * forceToApply;
} else {
if (pushObjectsFromPlayerForwardDirection) {
currentForceToApply = playerGameObject.transform.forward * forceToApply;
} else {
currentForceToApply = mainCameraTransform.TransformDirection (Vector3.forward) * forceToApply;
}
}
if (currentForceToApply != Vector3.zero) {
objectToDamageMainRigidbody = currentObject.GetComponent<Rigidbody> ();
objectToDamageMainRigidbody.AddForce (currentForceToApply * objectToDamageMainRigidbody.mass, forceMode);
}
if (!callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (currentObject);
}
rigidbodyFound = true;
}
}
if (!rigidbodyFound) {
checkRemoteEvent (currentObject);
}
}
}
public void setPowerEnabledState (bool state)
{
powerEnabled = state;
initializeComponents ();
if (powerEnabled) {
gameObjectsFoundList.Clear ();
}
}
public void cleanGameObjectFoundList ()
{
gameObjectsFoundList.Clear ();
}
public void checkRemoteEvent (GameObject objectToCheck)
{
if (useRemoteEventOnObjectsFound) {
remoteEventSystem currentRemoteEventSystem = GKC_Utils.getRemoteEventSystemFromObject (objectToCheck, true);
if (currentRemoteEventSystem != null) {
int remoteEventNameListCount = remoteEventNameList.Count;
for (int i = 0; i < remoteEventNameListCount; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameList [i]);
}
}
}
}
public void setUseRemoteEventOnObjectsFoundState (bool state)
{
useRemoteEventOnObjectsFound = state;
}
public void setUseMessageToPushCharactersFoundState (bool state)
{
useMessageToPushCharactersFound = state;
}
public void setUseOfPowerPausedState (bool state)
{
useOfPowerPaused = state;
}
public void setNewPushCenterDistance (float newValue)
{
pushCenterDistance = newValue;
}
void initializeComponents ()
{
if (componentsInitialized) {
return;
}
if (mainPlayerWeaponSystem != null) {
playerGameObject = mainPlayerWeaponSystem.getPlayerWeaponsManger ().gameObject;
if (playerGameObject != null) {
playerComponentsManager mainPlayerComponentsManager = playerGameObject.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
powersManager = mainPlayerComponentsManager.getOtherPowers ();
mainCameraTransform = mainPlayerComponentsManager.getPlayerCamera ().getCameraTransform ();
}
}
}
componentsInitialized = true;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9dee34cafbc74a44a9f08ac62ebb7d59
timeCreated: 1537152992
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/pushObjectsPower.cs
uploadId: 814740

View File

@@ -0,0 +1,97 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class useDevicesAtDistancePower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled;
public LayerMask layer;
public List<string> tagToCheck = new List<string> ();
public bool useInfiniteRaycastDistance = true;
public float raycastDistance = 100;
public bool ignoreDeviceToControlAtDistanceComponent;
[Space]
[Header ("Components")]
[Space]
public usingDevicesSystem usingDevicesManager;
public Transform mainCameraTransform;
public playerInputManager playerInput;
public Collider playerCollider;
public GameObject player;
RaycastHit hit;
GameObject currentDeviceToUse;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
float currentRaycastDistance = raycastDistance;
if (useInfiniteRaycastDistance) {
currentRaycastDistance = Mathf.Infinity;
}
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, currentRaycastDistance, layer)) {
if (hit.collider.isTrigger && tagToCheck.Contains (hit.collider.tag)) {
currentDeviceToUse = hit.collider.gameObject;
if (!ignoreDeviceToControlAtDistanceComponent) {
deviceToControlAtDistance currentDeviceToControlAtDistance = currentDeviceToUse.GetComponent<deviceToControlAtDistance> ();
if (currentDeviceToControlAtDistance != null) {
if (!currentDeviceToControlAtDistance.isDeviceToControlEnabled ()) {
return;
}
currentDeviceToUse = currentDeviceToControlAtDistance.getDeviceToControlGameObject ();
}
}
electronicDevice currentElectronicDevice = currentDeviceToUse.GetComponent<electronicDevice> ();
if (currentElectronicDevice != null) {
currentElectronicDevice.checkTriggerInfo (playerCollider, true);
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
simpleSwitch currentSimpleSwitch = currentDeviceToUse.GetComponent<simpleSwitch> ();
if (currentSimpleSwitch != null) {
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
inventoryObject currentInventoryObject = currentDeviceToUse.GetComponent<inventoryObject> ();
if (currentInventoryObject != null) {
pickUpObject currentPickupObject = currentDeviceToUse.GetComponentInParent<pickUpObject> ();
if (currentPickupObject != null) {
currentPickupObject.checkTriggerInfo (playerCollider);
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1324e98dff7d8ad46b269e93cee9941e
timeCreated: 1537317271
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Powers/New Powers Behaviors/useDevicesAtDistancePower.cs
uploadId: 814740