[QUOTE=secundus;44753819]Make another particle that does what you want (fireball getting smaller). Make it as a prefab, and on your fireball script, reference the created prefab and spawn it when the fireball hits something.[/QUOTE]
Ah sweet! So to do the actual animation, do I copy over the fireball particle system I created and then somehow animate it down?
[QUOTE=AtomiCal;44753887]A shot in the dark
Why is it when I force RenderTextureFormat.ARGB32 on every device, which makes every color channel have 8 bit precision. Make my shader act normal on my nexus and different on a mobile device?
I set it to low precision on purpose.[/QUOTE]
the format probably isn't available on all devices for whatever reason
why are you forcing it anyway
[QUOTE=DarKSunrise;44754077]the format probably isn't available on all devices for whatever reason
why are you forcing it anyway[/QUOTE]
the ARGB32 format is available on the device
I make sure of that using SystemInfo.SupportsRenderTextureFormat(format)
Forcing it instead of using for example ARGBFloat is a workaround because some(almost all) devices has 8 bit precision on the color channels.
Making it look good is just tweaking of values.
I could ofcourse be using the encode/decodergba functions, but I didn't get them to work and the deadline for QA is in a couple of hours.
Anyways, the thing is that this shouldn't happen.
Here is how it looks on my nexus with the correct values and ARGB32
[img]http://puu.sh/8E24K.jpg[/img]
Here is how it looks on a samsung galaxy S4 with the correct values and ARGB32. The grid is constantly hitting its max height.
[img]http://puu.sh/8E4pj.jpg[/img]
I just need to know what is making it act like that.
[QUOTE=Over-Run;44754034]Ah sweet! So to do the actual animation, do I copy over the fireball particle system I created and then somehow animate it down?[/QUOTE]
You could create a duplicate of fireball, remove unneeded components (like collider) and just edit the particle system component. What I'd do for fireball fizzling out would be enabling size over lifetime (edit the curve to make particle smaller over time), enable colour over lifetime (fade alpha from 1 to 0 after 75% lifetime) and disable looping.
You'll need a script to remove the gameobject after the particle stops playing (or pool and recycle).
[QUOTE=secundus;44754329]You could create a duplicate of fireball, remove unneeded components (like collider) and just edit the particle system component. What I'd do for fireball fizzling out would be enabling size over lifetime (edit the curve to make particle smaller over time), enable colour over lifetime (fade alpha from 1 to 0 after 75% lifetime) and disable looping.
You'll need a script to remove the gameobject after the particle stops playing (or pool and recycle).[/QUOTE]
Great thanks I have something like that now.
I'm just having trouble trying to destroy it.
I have a FireballSpell_Shoot which is attached to the Fireball game object.
In the script I call a Coroutine DestroyFireball(), and after it I instantiate the fireballDestroy.
In the coroutine I destroy the original fireball, wait a second and destroy the FireballDestroy object. However it's not working
[code] IEnumerator DestroyFireball(){
Debug.Log("here");
Destroy(this.gameObject);
yield return new WaitForSeconds(1);
Debug.Log("here2");
Destroy(fireBallDestroy);
}[/code]
When debugging it only says Here, and never gets to here2. Any ideas?
EDIT
I'm guessing it's because I'm destroying the object and so the rest of the code never gets called. I'm not sure if that's how it works or not.
[QUOTE=Over-Run;44754507]Great thanks I have something like that now.
I'm just having trouble trying to destroy it.
I have a FireballSpell_Shoot which is attached to the Fireball game object.
In the script I call a Coroutine DestroyFireball(), and after it I instantiate the fireballDestroy.
In the coroutine I destroy the original fireball, wait a second and destroy the FireballDestroy object. However it's not working
[code] IEnumerator DestroyFireball(){
Debug.Log("here");
Destroy(this.gameObject);
yield return new WaitForSeconds(1);
Debug.Log("here2");
Destroy(fireBallDestroy);
}[/code]
When debugging it only says Here, and never gets to here2. Any ideas?[/QUOTE]
How are you starting the coroutine?
StartCoroutine(DestroyFireball());
Oh wait, just saw your edit - yeah that will do it.
Coroutines are managed by the monobehavior that started them AFAIK. Destroying the monobehavior (or the object containing the monobehaviour) will stop the coroutine from running.
Which is just as well, otherwise Unity would need to keep a reference to the monobehaviour (since that's where the function is running), and that would mean a "ghost" monobehaviour that is still executing even though the game object is destroyed.
[QUOTE=KillaMaaki;44754543]Oh wait, just saw your edit - yeah that will do it.
Coroutines are managed by the monobehavior that started them AFAIK. Destroying the monobehavior (or the object containing the monobehaviour) will stop the coroutine from running.
Which is just as well, otherwise Unity would need to keep a reference to the monobehaviour (since that's where the function is running), and that would mean a "ghost" monobehaviour that is still executing even though the game object is destroyed.[/QUOTE]
Ah I see, so I guess I will have to make a script to handle destroying the DestroyFireball prefab
Hm, starting to sound kind of messy.
What's your end goal here? Maybe we can help clean things up and refactor a bit.
can u pwn mine bots??
You control using WASD + Q and E for up and down.
LMB fires weapon and RMB fires rockets if you've picked them up.
[unity]https://dl.dropboxusercontent.com/u/3983801/unity/Adapt/adapty.unity3d[/unity]
Spaces also feel a fair bit cramped. It's difficult to maneuver around, and I also get frequently spawn camped by the AI ;-;
Otherwise, a very neat concept IMHO. Polish it up, get some decent art in there and a copy of Pro, and make it awesome (throw in some PBR, maybe motion blur, dirty lens effects, you get the picture).
[QUOTE=KillaMaaki;44754592]Hm, starting to sound kind of messy.
What's your end goal here? Maybe we can help clean things up and refactor a bit.[/QUOTE]
Yeah I was actually going to see later on in the month if some people could help me clean up my code. It's my first Unity project and its for my final year project so the code has to be as nice as possible.
[QUOTE=Over-Run;44754507]Great thanks I have something like that now.
I'm just having trouble trying to destroy it.
I have a FireballSpell_Shoot which is attached to the Fireball game object.
In the script I call a Coroutine DestroyFireball(), and after it I instantiate the fireballDestroy.
In the coroutine I destroy the original fireball, wait a second and destroy the FireballDestroy object. However it's not working
[code] IEnumerator DestroyFireball(){
Debug.Log("here");
Destroy(this.gameObject);
yield return new WaitForSeconds(1);
Debug.Log("here2");
Destroy(fireBallDestroy);
}[/code]
When debugging it only says Here, and never gets to here2. Any ideas?
EDIT
I'm guessing it's because I'm destroying the object and so the rest of the code never gets called. I'm not sure if that's how it works or not.[/QUOTE]
Divide responsibilities. Lets say you have a Mana pool and a fireball spell, it can be divided into several scripts:
Mana.cs - Manages mana removal and recovery. (Similar approach can be used for Health, just need an extra check whether health is 0 or not) Make public methods like:
[code]public bool deductMana(float amount) {
if(currentMana > amount) {
currentMana -= amount;
return true;
}
return false;
}[/code]
which can be used on other Caster scripts like:
[code]
Mana manaScript;
void Update() {
if(Input.GetButtonDown("Fire1") {
//assuming Mana script is referenced
if(manaScript.deductMana(manaCost))
SpawnProjectile();
}
}
[/code]
FireballCaster.cs - References Mana and FireballProjectile. When player casts fireball, check for mana. If available, deduct the required amount and spawn a Fireball GameObject.
FireballProjectile.cs - Attached to the Fireball GameObject. Responsible for fireball's movement (speed, direction). If fireball has a range/lifetime limit, put it here (Can also be written as a separate script, e.g. DelayedRemover.cs). If fireball collides with something, spawn a FireballExplosion GameObject, apply damage and delete the fireball.
DelayedRemover.cs - responsible on GameObject deletion after n seconds. Like:
[code]void Start() {
Destroy(gameObject, delayInSeconds);
}[/code]
As you can see, FireballCaster doesn't need to know what a fireball is capable of doing. What FireballCaster knows is that if player presses Fire1, check for mana and spawn a fireball if mana is available. As for the spawned fireball, it knows that it has somewhere to move, and if it collides with something it should commit suicide and spawn a particle effect.
Of course in practice there are lots of things to consider, like Fireball damage and projectile owner. If responsibilities are divided properly, implementing new features will be easier.
Oh lastly, go [url=http://docs.unity3d.com/Documentation/Manual/InstantiatingPrefabs.html]here for in depth explanation of Instantiate[/url]. Also [url=http://gameprogrammingpatterns.com/]Game Programming Patterns[/url] is a great read.
Thank you for the indepth response.
I think I fucked up by not considering this stuff from the beginning :(
Just new to Unity so I wasn't sure how stuff worked with each other and stuff like that! Hopefully by the end of the month I can clean up all the nastyness! A chunk of the marks I will receive will be for having nice code
After playing around with it for a day and doing some research I realized what was happening with my car thing and why it could slide nicely for a while and then suddenly flip. It appears that when the wheel is sliding there is a sudden increase in friction, contrary to all documentation. A quick google later I found out that it's because the friction curve for the wheelcolliders is all wrong as explained [url=http://forum.unity3d.com/threads/153340-Wheel-Friction-Curve-Revealed]here[/url].
Wonder if the unity team is aware of this, seems like a big issue.
Maybe there's a way around this by dynamically changing the asymptoteValue as the slip increases so that it's more or less correct?
On the topic of destroying things, I am trying to destroy a Light which pulses.
The light lives for 10 seconds, and I want the instantiate a destroy light prefab which just fades the light away. How can I instantiate the new lightPrefab just before the old one is destroyed?
Is the light already pulsing or are you trying to use Destroy() and Instantiate() to make the pulse effect? If its the latter, don't do it that way.
One way to do it is to access the light component and interpolate its intensity value via script.
Another way to do it is to alter the intensity value via Animation editor and set it to loop. With this method you'll be using Animator component and Mecanim.
So basically I shoot the light.
This instantiates the Light_Shot prefab that has a light attached and a particle system to give a floating light look. This lasts for 10 seconds with a pulse effect that is done in a script.
That script basically says to destroy itself after 10 seconds, before hand it starts a Coroutine that calls the DestroyLightPrefab after 10 seconds.
The DestroyLightPrefab is just another particle system that fades away after a second so the light doesn't just disappear. However in game it is acting weird and just going disappearing, even though when I simulate the particle system it fades nicely.
In that case, after 10 seconds:
1) Stop the particle system by using particleSystem.Stop() (This will stop emitting new particles, old particles will still play until their lifetime ends).
2) Fade out the light (your choice of implementation).
3) After the light fades out completely, clean up.
For GameObject with ParticleSystem, you can also remove them by checking whether the ParticleSystem has remaining live particles with [url=https://docs.unity3d.com/Documentation/ScriptReference/ParticleSystem.IsAlive.html]particleSystem.IsAlive()[/url]. The example shows exactly how to do auto particle system destroyer.
Ah that actually sounds much better than the way I was doing it (Copying and pasting the old particle system and adding in a fade effect).
Thanks man
If you play and Audio Source, can it be stopped/muted, mid way through?
I'm implementing a slow motion spell, and when I go slow motion, I play a transition sound and then have a constant looping sound effect while the player is in slow motion.
When the player presses the button again it plays an exit sound and trys to stop the looping sound but the looping sound keeps playing?
[code]
inSlowMo.Stop();
inSlowMo.mute = true;
[/code]
Any ideas?
You sure you referenced the correct AudioSource component?
Yeah I ended up fixing it. Turned out it was an issue with the file type I was using, just converted to .wav and it ended up working.
Any ideas on how I can get a nice screen effect when in slow motion? Some sort of screen glow or something? Not sure on what would work
If you have Unity Pro then its possible to do image effects like grayscale, colour invert etc.
LINQ in Unity, yummy :D!
(Don't worry guys, I just use it in start for initialization)
Perfect, got some sweet slow mo goodness going on now. Just need to figure out how to make the physics move smoothly.
EDIT
And done.
Man this is going to be so fun in the Oculus Rift. Running up a hill and having a boulder fall down and then using your slow motion spell to quickly move out of the way. Can't wait to have a working level
When you apply slow motion using Time.timeScale, multiply the new timeScale with [url=http://docs.unity3d.com/Documentation/ScriptReference/Time-timeScale.html]Time.fixedDeltaTime as well[/url]. FixedUpdate rate is affected with time scale, a time scale of 0 will make FixedUpdate to not be called at all.
This will fix your physics since physics update is performed during FixedUpdate intervals. Make sure to revert your fixedDeltaTime after you set timeScale to 1, cause if you run the game at timeScale = 1 and uses the fixedDeltaTime that you set when timeScale = 0.5, FixedUpdate will be called 100 times instead of the default 50.
so uh how many light probes is too many light probes anyway
[img]http://i.imgur.com/kSq9rr8.png[/img]
[QUOTE=The Rizzler;44763629]so uh how many light probes is too many light probes anyway
[/QUOTE]
Doesn't matter. Won't slow anything down, anyway.
Sorry, you need to Log In to post a reply to this thread.