[QUOTE=gonzalolog;44646530]Maybe a stupid question, but...How many of your guys are using unity pro...Free
I would like to use it but already i bought some plugins :v
So agree if you're using a free version
And disagree for the basic version[/QUOTE]
What do you mean by "basic version"?
[QUOTE=KillaMaaki;44646672]What do you mean by "basic version"?[/QUOTE]
The gray, the one that doesn't let you play with screen effects, a profiler, the occluder and the nice dark gui
So my options are cracked free version, or actual free version?
Neither. Full version of pro.
How do I make it so that I can add a script to another script as a public variable.
I have one script which every Enemy Projectile has, but I want every projectile to have a second script which controlls the way the projectile is destroyed, so I want to have a public script variable in the Projectile Script where I can put the Destroy Script into.
This is basically the Projectile Script
[code]
using UnityEngine;
using System.Collections;
public class EnemyProjectile : MonoBehaviour
{
public _ProjectileDestroy destroyScript;
void destroy()
{
destroyScript.destroy();
controller.score += 1;
}
}
[/code]
And this is the Destroy Script and the Script it inherits from.
[code]
using UnityEngine;
using System.Collections;
abstract public class _ProjectileDestroy : MonoBehaviour
{
public virtual void Start ()
{
}
public virtual void Update ()
{
}
public virtual void destroy()
{
}
}
[/code]
[code]
using UnityEngine;
using System.Collections;
public class Meteor : _ProjectileDestroy
{
void Start ()
{
transform.Find ("Mesh").gameObject.rigidbody.angularVelocity = Random.insideUnitSphere*5;
}
public override void destroy()
{
Transform PE = transform.Find ("Mesh").transform.Find ("Trail");
if(PE != null)
{
PE.particleSystem.Stop ();
PE.parent = null;
Destroy (PE.gameObject, 2.0f);
Destroy (gameObject);
}
}
}
[/code]
Everything compiles fine, but when I want to put the meteor script into the slot where I am supposed to put a _ProjectileDestroy Script, it does'nt work :( .
I am sure there is just a really small problem that I just have'nt heard about yet how to solve this. If somebody could help I would be greatfull!
[QUOTE=Over-Run;44624445]
Wondering how can I make my light spell look more appealing.
It just looks really lifeless or something. I want a glow effect or some flare or something nice looking.
[/QUOTE]
I could make some particle effects for you if you're interested.
[QUOTE=freakadella;44648379]How do I make it so that I can add a script to another script as a public variable.
I have one script which every Enemy Projectile has, but I want every projectile to have a second script which controlls the way the projectile is destroyed, so I want to have a public script variable in the Projectile Script where I can put the Destroy Script into.
This is basically the Projectile Script
[code]
using UnityEngine;
using System.Collections;
public class EnemyProjectile : MonoBehaviour
{
public _ProjectileDestroy destroyScript;
void destroy()
{
destroyScript.destroy();
controller.score += 1;
}
}
[/code]
And this is the Destroy Script and the Script it inherits from.
[code]
using UnityEngine;
using System.Collections;
abstract public class _ProjectileDestroy : MonoBehaviour
{
public virtual void Start ()
{
}
public virtual void Update ()
{
}
public virtual void destroy()
{
}
}
[/code]
[code]
using UnityEngine;
using System.Collections;
public class Meteor : _ProjectileDestroy
{
void Start ()
{
transform.Find ("Mesh").gameObject.rigidbody.angularVelocity = Random.insideUnitSphere*5;
}
public override void destroy()
{
Transform PE = transform.Find ("Mesh").transform.Find ("Trail");
if(PE != null)
{
PE.particleSystem.Stop ();
PE.parent = null;
Destroy (PE.gameObject, 2.0f);
Destroy (gameObject);
}
}
}
[/code]
Everything compiles fine, but when I want to put the meteor script into the slot where I am supposed to put a _ProjectileDestroy Script, it does'nt work :( .
I am sure there is just a really small problem that I just have'nt heard about yet how to solve this. If somebody could help I would be greatfull![/QUOTE]
What do you mean by "it doesn't work"?
I'm making an ingame level editor for my game but I'm having a problem where loading a level causes null reference exceptions. This is because certain components aren't updating their references to the new ones. What would be the best way to tell all the gameobjects in the scene to update their references? And maybe stop what they're doing for a frame or two to give everything a chance to update?
[QUOTE=KillaMaaki;44649259]What do you mean by "it doesn't work"?[/QUOTE]
I cannot move the Meteor script into the spot in the inspector where the EnemyProjectile script wants the public _ProjectileDestroy script. It does not accept it.
<_< I did had a question eariler...
Agree this post if you want a cool subtitle script that I made.
So, I was wondering if you guys knew the best approach to adding collisions in this map, like to the walls and what not.
[IMG]http://i.imgur.com/PMUiEMm.png[/IMG]
Box colliders.
That seems quite time consuming..
Not only that, but to get all the colliders lined up properly for all the walls?
Isn't there a faster, more accurate way?
[QUOTE=sarge997;44668135]That seems quite time consuming..
Not only that, but to get all the colliders lined up properly for all the walls?
Isn't there a faster, more accurate way?[/QUOTE]
Why would there be? And how would it work? All you've got is a 2D image - that really isn't much to go on.
I would say what you probably want instead is a tile system. So instead of an image, you've got a tilemap. Each tile could then have some data determining whether or not it gets a collider. You'd have to write that yourself, however.
For some reason, ever since I started having "meteor" inherit from "projectile" which inherits from "object", Monodevelop tells me all the things that exist in monobehaviour, like "transform" or "Destroy", don't exist in the current context and highlights them in red, but it all works perfectly well in Unity. Is this a bug in Monodevelop?
[QUOTE=freakadella;44668208]For some reason, ever since I started having "meteor" inherit from "projectile" which inherits from "object", Monodevelop tells me all the things that exist in monobehaviour, like "transform" or "Destroy", don't exist in the current context and highlights them in red, but it all works perfectly well in Unity. Is this a bug in Monodevelop?[/QUOTE]
Wait, what? It inherits from "Object"??
Why on earth would you do such a thing??
[QUOTE=KillaMaaki;44668225]Wait, what? It inherits from "Object"??
Why on earth would you do such a thing??[/QUOTE]
yesh freakadella, change Object to GameObject
[QUOTE=HeatPipe;44668328]yesh freakadella, change Object to GameObject[/QUOTE]
Nope, GameObject is sealed. Can't inherit. Unity is a component-based engine and I think a while ago UT got tired of everybody inheriting from GameObject so they sealed it.
Anyway, the answer to everything in Unity is USE COMPONENTS! Inherit from MonoBehaviour! It's a [I]component-based engine[/I] after all.
:D I am sorry for the misleading name! Object is a Class I made! It has basic properties of every Object in my game.
[QUOTE=freakadella;44668488]:D I am sorry for the misleading name! Object is a Class I made! It has basic properties of every Object in my game.[/QUOTE]
What's your Object class look like?
(btw you should probably change the name - it's a bit confusing and could lead to compiler confusion)
LOOOOL !!! You said compiler confusion, so I just tested what would happen if I call it "Objecto"... it works fine now! :D
[editline]28th April 2014[/editline]
The name will stay Objecto from now on in your honour !
How do I stop an animation from teleporting my object back to the position it was in when I made the animation? I've tried removing all the keys pertaining to his position in the animation, I've tried turning 'apply root motion' on and off, nothing seems to work.
That's usually when I start putting things in empty game objects.
[QUOTE=pinecleandog;44671859]That's usually when I start putting things in empty game objects.[/QUOTE]
Tried it, no dice unfortunately. :(
Well here ya go. It does require a dynamic text font, but that's all there is to it. Feed in GUI skin and you're good to go.
[code]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SubtitleText : MonoBehaviour {
// public var
public float fade = 2f; // Fade tweens
public int offset = 24; // Character offset
public GUISkin skin; // Custom GUI skin for text customization : NOTE MUST BE DYNAMIC FONT!!!
// private var
public List<Paragraph> paragraph = new List<Paragraph>(); // Collections of paragrah
private List<StoredCaption> storedcap = new List<StoredCaption>(); // Collections of drawn message
void Start() {
foreach( Paragraph p in paragraph ) {
StartCoroutine( Subtitle( p ) ); // Start the timer
}
}
void OnGUI() { // Message drawn
if( skin != null ) GUI.skin = skin; // Make message center and customized
foreach( StoredCaption sp in storedcap ){
sp.UpdateVariable(); GUI.color = sp.color; // Update color and position
GUI.Label( sp.rect, sp.sentence ); // dislay message and it's fade effects
}
}
// How it's being drawn per timing
IEnumerator Subtitle( Paragraph p) {
yield return new WaitForSeconds( p.timeToStart ); // Cue to start displaying
StoredCaption sp = new StoredCaption(); // create a new entry
sp.Initialize(); // Generate the rect
sp.sentence = p.sentence; // store the sentence
storedcap.Add( sp ); // add the entry to the arraylist
foreach( StoredCaption cap in storedcap ) cap.Offset(offset); // be sure to offset every arraylist
yield return new WaitForSeconds( p.duration ); // End displaying
storedcap[storedcap.IndexOf(sp)].canFade = false; // make canfade false so that we can fade out
yield return new WaitForSeconds( fade ); // Fade out
storedcap.RemoveAt(0); // Clean up arraylist
}
/* <Summary>
* Each class has it's own definition of variables. One is used for storing it and how to
* display them proplery and the other is used to inistiate it. Store classes has a sub
* function so that it's calcuating the variable inside class */
[System.Serializable] // Despite that this class is private, we want other user to debug this and check for performance on memory useage.
public class StoredCaption { // Class of each message showed
public string sentence { get; set; } // message
public Color color = Color.clear; // message color
public float x, newPos, oldPos, fade = 2f; // width, positions, positions, fade duration
public Rect rect; public bool canFade = true; // Rect, bool
public void Offset(float i){ newPos -= i; } // Move message up once
public void Initialize() { // pseudo to void start
oldPos = newPos = Screen.height - 100; x = ( Screen.width - 800 ) / 2; // establish starting pos
rect = new Rect( x , oldPos , 800, 50 ); // Establish rect coordinate
}
public void UpdateVariable(){ // pseudo to void Update and lerps variables
color = Color.Lerp( color, canFade ? Color.white : Color.clear, Time.deltaTime / fade );
oldPos = Mathf.Lerp( oldPos, newPos, Time.deltaTime );
rect = new Rect( x, oldPos, 800, 50 );
}
}
[System.Serializable]
public class Paragraph{
public string sentence; // What message to draw
public float timeToStart; // when does it start
public float duration; // how long should the message last before disappearing into the void
}
}
[/code]
So has anybody ever had any issues with a rigidbody moving for no discernible reason? Basically I have a typical rigidbody that doesn't use gravity with a capsule collider, which I can fly around the scene. But sometimes after I collide with something the rigidbody starts moving slowly on its own. I've made sure that nothing is wrong with my scripts, even messing with the drag value does nothing. The only thing that makes it stop moving is setting it to kinematic.
Collision creates force? You could probably fix it by adding something like this to FixedUpdate.
[code]rigidbody.velocity *= 0.95f;[/code]
FUCKING ANGLES
sorry had to release my frustration
[editline]29th April 2014[/editline]
nevermind, case solved, thanks facepunch
Does anyone know how to make it so a gameobject isn't saved to disk in the scene? Currently I have a custom terrain system but the meshes and splat maps are using too much space for our source control. I tried using HideFlags but this gave me problems with serialization between the editor and play mode.
Terrain Progress so far:
[img]https://dl.dropboxusercontent.com/u/3715122/Coding/Unity/Capture.PNG[/img]
I was wondering because I need to make sure my code is as nice as possible for my project demonstration. Is coding in Unity object orientated? I'm just confused as you make scripts and place them on things, so I'm not sure if it is OO. I have 4 magic spells in my game, but each spell has its own script. Is this a good way of doing it? Each spell does something different so I'm just not sure on how to make sure I have the best code possible
Yea, Unity coding is OO.
You should look at your spells and see if they share any big chunks of code. If you repeat yourself a lot, you should think about what of that you can put into some kind of base class. If you don't have a base class for spells yet, you're probably not keeping it DRY (Don't Repeat Yourself).
Sorry, you need to Log In to post a reply to this thread.