|
Post by pigame on Aug 13, 2016 22:11:32 GMT
The attack and skill would look more powerful with camera shaking effect (like earth quake), how can I do that Invector? Where should I look to make changes? Or is it already built-in in the Controller how can I call it? I think lot of other users would love to have that effect too. :D Thank you for your time! :D
|
|
|
Post by Invector on Aug 14, 2016 12:45:42 GMT
Currently our camera doens't have a shake effect, but it's definitely a nice touch to add, I will put it on the list ;)
|
|
|
Post by jgiroux on Aug 14, 2016 20:21:52 GMT
Shake Camera Effect is always a welcome addition. here, try this in the meantime
create a new c# script and call it "CameraShakeAddOn" (without the quotes). open up that script and remove everything in there. copy and paste the below code. then save/compile/build.
using UnityEngine; using System.Collections; using Invector.CharacterController; using Invector; // simple script addon for InvectorCamera to allow screenshakes // feel free to use as is or edited
public class CameraShakeAddOn : MonoBehaviour { private Vector3 MainCamera_OriginalPosition; private Quaternion MainCamera_OriginalRotation; private float MainCamera_ShakeStrength; //public variables public vThirdPersonController myController; // link thirdPersonController // public float Intensity = 0.02f; // intensity of CameraShake public float DecayTime = 0.001f; // how long it takes camera to return to normal public bool ShakeCamera; // a easy public bool to trigger when to shake camera
public void Update() { if (myController != null) // if controller is not active ignore { if (myController.GetComponent<vThirdPersonMotor>().hud.damaged == true) { ShakeCamera = true; } } if (ShakeCamera == true) { Shake(); ShakeCamera = false; }
if (MainCamera_ShakeStrength > 0) { transform.position = MainCamera_OriginalPosition + Random.insideUnitSphere * MainCamera_ShakeStrength; transform.rotation = new Quaternion ( MainCamera_OriginalRotation.x + Random.Range(-MainCamera_ShakeStrength, MainCamera_ShakeStrength) * .2f, MainCamera_OriginalRotation.y + Random.Range(-MainCamera_ShakeStrength, MainCamera_ShakeStrength) * .2f, MainCamera_OriginalRotation.z + Random.Range(-MainCamera_ShakeStrength, MainCamera_ShakeStrength) * .2f, MainCamera_OriginalRotation.w + Random.Range(-MainCamera_ShakeStrength, MainCamera_ShakeStrength) * .2f ); MainCamera_ShakeStrength -= DecayTime; } }
private void Shake() // function to shake camera { MainCamera_OriginalPosition = transform.position; MainCamera_OriginalRotation = transform.rotation; MainCamera_ShakeStrength = Intensity; } }
Now add this script to your 3rdPersonCamera. Steps. 1) Drag your Player Character into the "MyController" field in your Inspector 2) Adjust (if you like, however its set up with decent values) Intensity (how crazy the screen shakes) 3) Adjust (if you like, however its set up with decent values) DecayTime (how long it takes for camera to return to normal)
that's it. go try it out and have an enemy damage you, should trigger the screen shake.
of course, this script could be vastly improved upon, but its a start and works out of box, as it will check your Invectors Player for a Damage call and trigger the screen shake., but I made the ShakeScreen Boolean trigger a public variable, so you can call it from your own scripts to make further use of it.
also, this actually shakes screen on player damage, not on skills and attacks. but using the public bool as I mentioned you could easily access it a number of ways, just by setting MainCamera.GetComponent<CameraShakeAddOn>().ShakeCamera = true;
|
|
|
Post by pigame on Aug 15, 2016 2:39:25 GMT
OMG thank you so much jgiroux you're awesome, I'll try it right away XD
|
|