[QUOTE=Speedhax;40271899]I'm really liking what you're doing. It's going to be like mount and blade you said?[/QUOTE]
Kind of, yeah. You will be able to roam the star system in your ship (or fleet if I decide to allow that) and you can trade, smuggle, pirate, attack ships and space stations and stuff, set up business/industrial enterprises, become a crime lord, and maybe even take over governorship of colonies. There won't be a central sory/quest line to follow so you can do whatever you want.
[QUOTE=Orki;40271603]I've been doing 2d work in unity
The only problem i've had is that a gameobject takes forever to load when you need to draw 5-6 of the same sprite and there is no good way of doing several spritedrawings on the same quad when using spritesheets.(That i have figured out atleast)[/QUOTE]
You could probably use a surface shader on the quad to draw the same sprite in different places, or you could use the spritesheet on a single material and just call different UV coordinates depending on the tile or sprite you want. There's also the 2d framework plugin, which costs $60 and does all of that for you, as well as support for tilemaps, even isometric ones, it's really efficient, I've had hundreds of sprites on screen without any noticeable drop in FPS.
In other news, me and a couple of guys at work decided to work on a Haven and Hearth kind of game using Unity on our spare time, maybe we can convince our boss to get the whole team on it in a few months when we're done with our current projects.
[QUOTE=DeanWinchester;40272269]You could probably use a surface shader on the quad to draw the same sprite in different places, or you could use the spritesheet on a single material and just call different UV coordinates depending on the tile or sprite you want. There's also the 2d framework plugin, which costs $60 and does all of that for you, as well as support for tilemaps, even isometric ones, it's really efficient, I've had hundreds of sprites on screen without any noticeable drop in FPS.
In other news, me and a couple of guys at work decided to work on a Haven and Hearth kind of game using Unity on our spare time, maybe we can convince our boss to get the whole team on it in a few months when we're done with our current projects.[/QUOTE]
I use 2d toolkit for the work i do. but i'll look into your suggestions
[QUOTE=Pelf;40272231]Kind of, yeah. You will be able to roam the star system in your ship (or fleet if I decide to allow that) and you can trade, smuggle, pirate, attack ships and space stations and stuff, set up business/industrial enterprises, become a crime lord, and maybe even take over governorship of colonies. There won't be a central sory/quest line to follow so you can do whatever you want.[/QUOTE]
Interesting, hopefully it won't be as limiting as the X series. Plus not being able to wander in my ship killed my immersion in X3 lol.
Hey guys, I'm trying to step a bit outside of lua, and take on other languages and work with an engine. I've had a bit of experience with C# but a lot with lua and I'm not sure whether to choose between this and CryEngine, which do you guys suggest?
Sat down and taught myself how to use Unity today, was really proud of my first project.
[media]http://www.youtube.com/watch?v=-ikAFsE8qSc[/media]
[QUOTE=Silentfood;40273447]Sat down and taught myself how to use Unity today, was really proud of my first project.
[media]http://www.youtube.com/watch?v=-ikAFsE8qSc[/media][/QUOTE]
Assuming you're using the free version, how'd you do the flashlight?
-snap ur fingers-
[QUOTE=Chris220;40273565]Assuming you're using the free version, how'd you do the flashlight?[/QUOTE]
Shadow/light projectors, they're part of the Unity packages included with the free version
[QUOTE=Chris220;40273565]Assuming you're using the free version, how'd you do the flashlight?[/QUOTE]
Yeah the free version using JavaScript, I parented a spot light with flash light settings (big radius, not too bright) to the lens of the flashlight. I have a script that lets me hit 1 and 2 to change between gun and the flashlight, when a tool isn't active, it disables rendering on the handle and lens (.renderer.enabled = false).
It also disables the light (.light.enabled = false). Also to parent you just drag them under the objects in the hierarchy and they will follow the localPosition rule.
I'm still not all too clear on what unity free does and doesn't have in terms of lights, it's a bit confusing to me at the moment.
[QUOTE=Chris220;40273891]I'm still not all too clear on what unity free does and doesn't have in terms of lights, it's a bit confusing to me at the moment.[/QUOTE]
Both Free and Pro has 4 types of light: Point, Directional, Spot Light and Area (only for lightmap baking). Both versions support vertex lighting and pixel lighting.
Main difference between Free and Pro is that Pro's light sources support real time shadows.
Me and a friend made a zombie game. AD to move, space to jump, R to reload [URL="http://donkie.dorkins.net/zombs.html"]linky[/URL]
[IMG]http://puu.sh/2zSgZ/0de37cce9c[/IMG]
Code Review? I made a character controller. It can control a rigid body or a normal object. It works - but am I doing anything stupid?
[code]using UnityEngine;
using System.Collections;
public class PlayerControlSimple : MonoBehaviour
{
public Vector3 curVelocity;
public float acceleration = 100.0f;
public float kinematicDrag = 10.0f;
public float maxSpeed = 100.0f;
public Vector3 vecRight = new Vector3( 1, 0, 0 );
public Vector3 vecForward = new Vector3( 0, 0, 1 );
public bool faceTowardsVelocity = true;
public float turnSpeed = 0.33f;
protected Vector3 lerpedFaceVector = new Vector3( 0, 0, 0 );
void FixedUpdate()
{
bool useKinematics = ( rigidbody == null || rigidbody.isKinematic );
//
// If we're controlling a physics object then inherit its velocity.
// This allows us to be chucked around.
//
if ( !useKinematics )
{
curVelocity = new Vector3( 0, 0, 0 );
}
else
{
//
// Apply kinematic drag
//
if ( curVelocity.magnitude > kinematicDrag * Time.deltaTime )
curVelocity *= ( (curVelocity.magnitude - kinematicDrag * Time.deltaTime ) / curVelocity.magnitude ) ;
else
curVelocity *= 0.5f;
}
float move_x = Input.GetAxis( "Horizontal" );
float move_y = Input.GetAxis( "Vertical" );
//
// Add movement velocity
//
curVelocity += vecRight * move_x * Time.deltaTime * acceleration;
curVelocity += vecForward * move_y * Time.deltaTime * acceleration;
//
// If we're kinematic (or have no physics) then just move the
// entity. If we have physics then apply the velocity directly.
//
if ( useKinematics )
{
//
// Clamp to max speed
//
if ( curVelocity.magnitude > maxSpeed )
{
curVelocity = curVelocity.normalized * maxSpeed;
}
transform.position += curVelocity * Time.deltaTime;
}
else
{
//
// If we're going too fast, don't let us push any faster in this direction
// but let us slow ourselves down by pressing the other way.
//
if ( rigidbody.velocity.magnitude > maxSpeed && Vector3.Dot( rigidbody.velocity, curVelocity ) >= 0.9f )
{
curVelocity *= 0.0f;
}
rigidbody.AddForce( curVelocity * rigidbody.mass * 1000.0f * Time.deltaTime );
}
//
// Face towards velocity
//
if ( faceTowardsVelocity && curVelocity.magnitude > 0.0f )
{
// If we're facing the completely opposite way we need to fudge it or it will rotatloe a weird way
if ( Vector3.Dot( lerpedFaceVector, curVelocity ) <= -0.99f )
lerpedFaceVector = curVelocity;
// approach
lerpedFaceVector = Vector3.Lerp( lerpedFaceVector, curVelocity, turnSpeed );
lerpedFaceVector.Normalize();
transform.LookAt( transform.position + lerpedFaceVector );
}
}
}
[/code]
Instead of vecRight and vecForward, why not use [url=http://docs.unity3d.com/Documentation/ScriptReference/Vector3-right.html]Vector3.right[/url] and [url=http://docs.unity3d.com/Documentation/ScriptReference/Vector3-forward.html]Vector3.forward[/url] instead?
Also this line:
[code]rigidbody.AddForce( curVelocity * rigidbody.mass * 1000.0f * Time.deltaTime );[/code]
Can be changed to this, I think:
[code]rigidbody.AddForce( curVelocity * 1000.0f * Time.deltaTime, ForceMode.Acceleration );[/code]
By default, AddForce uses [url=http://docs.unity3d.com/Documentation/ScriptReference/ForceMode.html]ForceMode[/url].Force, which applies continuous force using its mass, while ForceMode.Acceleration ignores mass.
I let you define what direction left and forward is... this is assuming that the camera angle is static instead of using the rotation of the player entity.
I will try the mass thing - thanks! That's a good tip!
[QUOTE=garry;40275410]Code Review? I made a character controller. It can control a rigid body or a normal object. It works - but am I doing anything stupid?
[/QUOTE]
For public stuff, I would suggest using properties. This looks like you're too used to writing C++. Same thing with your Save/Restore system. For that, you could actually use .NET features such as its built in serialisation and making use of attributes.
Assuming camera angle is static, you can make it automatically handle left/forward direction (like how AngryBots did it):
[code]
Quaternion screenSpace;
Vector3 screenForward;
Vector3 screenRight;
void Start()
{
// Camera is static in rotation, so we only calculate it once
screenSpace = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
screenForward = screenSpace * Vector3.forward;
screenRight = screenSpace * Vector3.right;
}
[/code]
And your user Input from this:
[code]
float move_x = Input.GetAxis( "Horizontal" );
float move_y = Input.GetAxis( "Vertical" );
//
// Add movement velocity
//
curVelocity += vecRight * move_x * Time.deltaTime * acceleration;
curVelocity += vecForward * move_y * Time.deltaTime * acceleration;
[/code]
to this:
[code]
curVelocity += (Input.GetAxis ("Horizontal") * screenRight + Input.GetAxis ("Vertical") * screenForward) * acceleration * Time.deltaTime;[/code]
Is slippery movement intentional?
[QUOTE=SteveUK;40276419]For public stuff, I would suggest using properties. This looks like you're too used to writing C++. Same thing with your Save/Restore system. For that, you could actually use .NET features such as its built in serialisation and making use of attributes.[/QUOTE]
Can you give me an example?
[editline]14th April 2013[/editline]
[QUOTE=secundus;40276428]Assuming camera angle is static, you can make it automatically handle left/forward direction (like how AngryBots did it):
[code]
Quaternion screenSpace;
Vector3 screenForward;
Vector3 screenRight;
void Start()
{
// Camera is static in rotation, so we only calculate it once
screenSpace = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
screenForward = screenSpace * Vector3.forward;
screenRight = screenSpace * Vector3.right;
}
[/code]
And your user Input from this:
[code]
float move_x = Input.GetAxis( "Horizontal" );
float move_y = Input.GetAxis( "Vertical" );
//
// Add movement velocity
//
curVelocity += vecRight * move_x * Time.deltaTime * acceleration;
curVelocity += vecForward * move_y * Time.deltaTime * acceleration;
[/code]
to this:
[code]
curVelocity += (Input.GetAxis ("Horizontal") * screenRight + Input.GetAxis ("Vertical") * screenForward) * acceleration * Time.deltaTime;[/code]
Is slippery movement intentional?[/QUOTE]
Yeah the problem is that in the game I made the direction wasn't really related to the camera angle.. so I couldn't do it like that. I thought this might be the best tradeoff.
[url]https://dl.dropboxusercontent.com/u/3590255/Tests/Approval/0000003/full.html[/url] is the game.
[QUOTE=garry;40276472]Can you give me an example?[/QUOTE]
[url=http://msdn.microsoft.com/en-gb/library/x9fsa0sw(v=vs.100).aspx]Properties[/url] are basically replacements for getters and setters in other languages. They are referenced like variables but you can completely control the behaviour of the get/set. You can have a private set to effectively make it a readonly property. But most of the time you can use [url=http://msdn.microsoft.com/en-GB/library/bb384054.aspx]auto-implemented properties[/url] which create the variables for you.
There's plenty on Google about serialisation in .NET.
[url=http://msdn.microsoft.com/en-gb/library/z0w1kczw(v=vs.100).aspx]Attributes[/url] allow you to add attributes to classes, functions, properties and other members. So you might want to add a SaveAttribute which determines which properties are saved to file. You can use reflection to see which properties have what attributes.
But why would I want to do that? What's wrong with what I'm doing now?
[QUOTE=garry;40276561]But why would I want to do that? What's wrong with what I'm doing now?[/QUOTE]
Why do encapsulation then? You can have a public get and a private/protected set, for example. It can also be used for error checking, custom output and validation.
Using serialisation for a save system, for example, would just make it a lot more elegant to deal with in the long run. Did you also [url=http://msdn.microsoft.com/en-gb/library/ms229752(v=vs.100).aspx]see this[/url] before making your save system?
So you should do that just so you can make them protected/private? I understand why people would want to do that (although I think it's just making work for yourself).
The reason I made them public was I wanted them to show up in the editor, like this:
[img]http://i.imm.io/12RH0.png[/img]
Does your method keep that rocking?
Yeah I saw the serialization stuff. I decided against it, and to do it in a low level straight forward way - because I could see a lot of ways that system could end up fucking me in the ass.
IIRC Unity does not expose properties in inspector natively, and to do so requires writing your own custom inspector.
It does expose attributes in inspector, example would be AngryBots' SignalSender.js (used in Health.js).
Ok then I see no reason at all to swap them to private with getter/setters. It's pointless.
[QUOTE=garry;40276714]Ok then I see no reason at all to swap them to private with getter/setters. It's pointless.[/QUOTE]
It might be pointless until you actually need one. It's always worth considering what's available to you.
And with the built in version tolerant serialisation, I imagine you're just duplicating work since you can set the version the property was added, and you can tell it what to ignore. It's a feature that's already there and so far looks like you're replicating it.
But when I need it can't I just add it? It seems to make more sense than adding it to everything on the off chance of needing it?
With the serialization thing.. if I rename a variable, or change it from a bool to an int.. how would the serialization stuff handle that? Would it be able to load old saves still?
I've always wanted to write terrain generation in unity, anyone ever try it?
-snip- Figured it out
Is your game first person?
Why not having all player input in one place rather than scattered across all scripts, like a PlayerController or something?
With that you can have something like:
YourPlayerController.cs
[code]
void Update()
{
// Using GetButtonDown rather than GetKeyDown is much more preferable due to the fact that
// player can reassign key from default to any key they prefer.
// You'll have to add "Use" and "Align Ground" yourself in Edit > Project Settings > Input for it to work
if(Input.GetButtonDown("Use") || Input.GetButtonDown("Align Ground"))
{
RaycastHit hit = new RaycastHit();
// origin, in this case, should be from the center of the camera
// transform.TransformDirection(Vector3.forward) gets the local forward axis rather than world, in this case it should always pointing forward relative to camera's view
// raycastDistance is the length of ray
Physics.Raycast(origin, transform.TransformDirection (Vector3.forward), out hit, raycastDistance);
if(hit.collider.tag == "Door")
{
Door dr = hit.transform.GetComponent<Door>();
if(!dr)
Debug.Log("What bullshit is this where is Door.cs wow how could you forget are you stupid or something?");
else
dr.SwitchOpenClose();
}
// Example of what other things can be done with "Use" button
else if(hit.collider.tag == "Enemy")
{
Health hp = hit.transform.GetComponent<Health>();
hp.OnDamage(10000);
}
else
{
// Play beep sound like Half Life does or something
}
}
// Other codes like movement or something
}
[/code]
And then your Door.cs have something like this:
[code]
Using ....
Using ....
public class Door : MonoBehaviour
{
bool isOpen = false;
public void SwitchOpenClose()
{
if(isOpen)
// Do open door stuff
else
// Do close door stuff
}
}
[/code]
EDIT: Wow took me so long to reply until you figured it out yourself.
Sorry, you need to Log In to post a reply to this thread.