Simple question here (I hope), I want to turn this Java script in to c# script:[CODE]#pragma strict
function Start () {
}
function Update ()
{
//gets the size of the screen in pixels then divides that number by 2
var halfW: float = Screen.width/2;
//will move the paddle with mouse left and right
transform.position.x = (Input.mousePosition.x -halfW)/(halfW);
//gets the size of the screen in pixels then divides that number by 3
var thirdH: float = Screen.height/3;
//will move the paddle with mouse in and out
transform.position.z = (Input.mousePosition.y -thirdH)/(thirdH);
}[/CODE]
Nvm, I made it out to be more complex than it truly is :
[CODE]using UnityEngine;
using System.Collections;
public class MouseFollow : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
//gets the size of the screen in pixels then divides that number by 2
float halfW = Screen.width/2;
//will move the paddle with mouse left and right
float x = (Input.mousePosition.x -halfW)/(halfW);
//gets the size of the screen in pixels then divides that number by 3
float thirdH = Screen.height/3;
//will move the paddle with mouse in and out
float z = (Input.mousePosition.y -thirdH)/(thirdH);
transform.position = new Vector3 (x,0,z);
}
}
[/CODE]
This works but if there any other suggestions out there I would still appreciate it.
[QUOTE=omiver;40948380]Simple question here (I hope), I want to turn this Java script in to c# script:[/QUOTE]
[CODE]
void Update ()
{
//gets the size of the screen in pixels then divides that number by 2
float halfW = Screen.width/2;
//will move the paddle with mouse left and right
transform.position.x = (Input.mousePosition.x -halfW)/(halfW);
//gets the size of the screen in pixels then divides that number by 3
float thirdH = Screen.height/3;
//will move the paddle with mouse in and out
transform.position.z = (Input.mousePosition.y -thirdH)/(thirdH);
}[/CODE]
See if this works.
[editline]8th June 2013[/editline]
Oh, you already did it. :(
sometimes messing up makes the most beautiful things
[t]http://i.imgur.com/CsPASaZ.png[/t]
[QUOTE=Silentfood;40948945]sometimes messing up makes the most beautiful things
[t]http://i.imgur.com/CsPASaZ.png[/t][/QUOTE]
Sine wave?
[QUOTE=nVidia;40949024]Sine wave?[/QUOTE]
To be honest, I'm not even sure. I just did this and it majorly tripped out.
[code]
private float Perlin(float x, float z, float parentx,float parentz, float height)
{
float heightmapWidth = 555;
float heightmapHeight = 555;
x = x + parentx;
z = z + parentz;
float SCAPE_LEVEL = Mathf.PerlinNoise(x / heightmapWidth, y / heightmapHeight);
float perlinValue_a = Mathf.PerlinNoise((x / (heightmapWidth/3)) * 2, (z / (heightmapHeight/3)) * 2) * (height/2);
float perlinValue_b = Mathf.PerlinNoise((x / (heightmapWidth/SCAPE_LEVEL)) * 5, (z / (heightmapHeight/SCAPE_LEVEL)) * 5) * (height/2);
return (perlinValue_a + perlinValue_b) * 1.0f;
}
[/code]
First time using Unity, implemented Bezier curves and used it for creating paths for the camera.
[unity]https://dl.dropboxusercontent.com/s/1k0xbnqrrvlsitj/Platformer.unity3d?token_hash=AAEAZRk0r1M7JZmtI9sz4Nwn186SVQWayEK8cLBWd9uTnQ&dl=1[/unity]
[QUOTE=Hiruty;40969704]First time using Unity, implemented Bezier curves and used it for creating paths for the camera.
[unity]https://dl.dropboxusercontent.com/s/1k0xbnqrrvlsitj/Platformer.unity3d?token_hash=AAEAZRk0r1M7JZmtI9sz4Nwn186SVQWayEK8cLBWd9uTnQ&dl=1[/unity][/QUOTE]
I love how when you fall down it zooms out, as if it's a game over screen. :v:
I realise that's just demoing your bezier curves, but I hope you don't use that movement relative to camera style in whatever you make with it. That damn camera threw me off the edge of the level. :v:
[QUOTE=Chris220;40970041]I realise that's just demoing your bezier curves, but I hope you don't use that movement relative to camera style in whatever you make with it. That damn camera threw me off the edge of the level. :v:[/QUOTE]
Yeah, I'm using the standard 3rd person control. Later on I hope to create a better control scheme that doesn't throw you off. The only reason I put that ground there was cause I fell of so much :v:
How would I go about implementing guns into my game? Would I have a separate class for each gun, each with its own methods? Or should I combine common weapon functionality such as shooting and reloading into a single weapon handler script? Or something else entirely?
[QUOTE=Pelf;41032330]How would I go about implementing guns into my game? Would I have a separate class for each gun, each with its own methods? Or should I combine common weapon functionality such as shooting and reloading into a single weapon handler script? Or something else entirely?[/QUOTE]
I personally would have a base class with delegates, create different kinds of weapon scripts with their own functionality, and assign the needed functions to the needed callers when you want.
[editline]14th June 2013[/editline]
Or something, I'm not very good with C#
[QUOTE=Pelf;41032330]How would I go about implementing guns into my game? Would I have a separate class for each gun, each with its own methods? Or should I combine common weapon functionality such as shooting and reloading into a single weapon handler script? Or something else entirely?[/QUOTE]
The latter. If you use the former, its going to cause problem if you're going to access it by code.
Create a base class that all firearms would have, most of the time its enough to support a shooter.
A base class for firearms should have (but not limited to):
[code]
- spawn point (the origin when creating projectile or raycast)
- firing mode (3 firing mode: semi-auto, burst, automatic, use enum)
- weapon mode (projectile based or hitscan)
- damage (per each projectile hit)
- rate of fire (per second, for burst can be used for burst rate?)
- bullets per shot (assault rifle and pistol = 1, shotgun = 8 or 12)
- projectile speed (if you're using projectile based weapon and not hitscan)
- projectile prefab (if projectile based)
- force (e.g. knock back force per projectile)
- accuracy (base weapon accuracy, in cone angle)
- accuracy falloff (accuracy degradation per shot)
- accuracy recovery (recovery of accuracy over time)
- mag size
- reload speed (per second)
- reload mode (shotguns have different reload mechanic than magazine-based weapons)
[/code]
With just above, we can create several weapons from it:
[code]
Pistol:
- firing mode: semi-auto
- weapon mode: hitscan
- damage: 12
- rate of fire: 3.3
- bullets per shot: 1
- projectile speed: 0 (not used)
- projectile prefab: null (not used)
- force: 5
- accuracy: 20 (80% accuracy)
- accuracy falloff: 5
- accuracy recovery: 2
- mag size: 12
- reload speed: 3
- reload mode: mag change
Shotgun:
- firing mode: auto
- weapon mode: hitscan
- damage: 4
- rate of fire: 1.2
- bullets per shot: 8
- projectile speed: 0 (not used)
- projectile prefab: null (not used)
- force: 2
- accuracy: 40 (60% accuracy)
- accuracy falloff: 0
- accuracy recovery: 0
- mag size: 8
- reload speed: 0.8
- reload mode: per slug[/code]
For weapons like rocket launcher, the explosion is handled by its projectile(rocket) prefab(what happens if rocket collide with stuff).
Check AngryBots and Bootcamp and see how they implement guns.
So, making my first Unity game. Will someone help me figure out how to get some realistic grass because every grass shader I've seen turns out to be this weird pure green color:
[unity]https://dl.dropboxusercontent.com/u/69387792/Unity/Build%20Folder.unity3d[/unity]
[QUOTE=WitheredGryphon;41069915]So, making my first Unity game. Will someone help me figure out how to get some realistic grass because every grass shader I've seen turns out to be this weird pure green color:[/QUOTE]
I haven't tried it but it's worth a shot, have a look at Advanced Terrain Shader v2 since it's free, includes a different grass shader.
[url]https://www.assetstore.unity3d.com/#/content/2680[/url]
Did you guys know that if you divide your models into ~300 triangle parts (sub-objects) it will only use 1 draw call for all of those models (provided they use the same material and texture maps), and if you make a texture atlas, together with UV coordinate shifting you could even have multiple models using the same material and texture map, effectively only using 1 draw call for all of them.
[img]http://i.imgur.com/4he9ogj.png[/img]
Tree concept, heavily inspired by Google's CubeSlam.
I'm probably going to take this to a survival direction. I'd love to implement systems to allow the creative expression of players, e.g. building your own settlements and making caves, etc. But I'm not quite sure how I'm going to tackle that.
The art style reminds me of Darwinia for some reason. I like it.
Has anyone thought about making a community project?
I've personally found that working together with people in a single Unity project is hell
Well, I understand what you mean, but isn't there like a way multiple people can work on the same project at the same time?
[url]http://unity3d.com/unity/collaboration/[/url]
[editline]19th June 2013[/editline]
Or you could use a method I recently read about, where one is the Asset Master, who controls the project, and all other people work in their own projects. Once you finish a feature, you ship it to a unitypackage to the Asset Master, who then adds it to the game.
[editline]19th June 2013[/editline]
[code]
void GenerateChunksAroundCamera() {
for( int x = -6 + Mathf.FloorToInt( cameraPosition.position.x / 200 ); x < 6 + Mathf.FloorToInt( cameraPosition.position.x / 200 ); x++ ) {
for( int y = -6 + Mathf.FloorToInt( cameraPosition.position.z / 200 ); y < 6 + Mathf.FloorToInt( cameraPosition.position.z / 200 ); y++ ) {
FindTerrainUnder( new Vector3( cameraPosition.position.x + x * 200, cameraPosition.position.y, cameraPosition.position.z + y * 200 ), x, y );
}
}
}
void FindTerrainUnder( Vector3 location, int x, int y ) {
RaycastHit hit;
if( !Physics.Raycast( location, new Vector3( location.x, -location.y, location.z ), out hit ) ) {
if( !terrainList.ContainsKey( x.ToString() + y.ToString() ) ) {
GenerateChunk( x, y );
}
}
}
[/code]
Any glaring math problems here? I'm attempting to generate chunks around the camera, but it skips the same chunks every time.
Aha, I see. But personally it'd be epic to have a open source project where all Facepunchers could jump on and code.
I didn't realize how gray and bleak my screenshots were until I added some color correction, together with fog and colored light
[img]http://i.imgur.com/PyT3nMK.png[/img]
[QUOTE=Persious;41093364]Well, I understand what you mean, but isn't there like a way multiple people can work on the same project at the same time?[/QUOTE]
I think it's just a matter of organisation and communication. I'm working on a prototype for our future game with my friend and we use bittorrent sync + git where I work in my own branch and then he merges when we reach a step worth of doing it. So far there has been no problem doing it like this but that's maybe because only him codes and I'm the art guy.
Yeah, exactly. I guess it get's more confusing if there are a few people coding and others doing other things.
Made an options menu for a game:
[t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-06/2013-06-24_09-32-07.png[/t]
How can I make a dropdown box for screen resolution/graphics quality/whatever else?
I'm pretty new to Unity. How would you say is the best way to make a button/image wobble from side to side and scale slightly in a similar way to the "Play' button on the candy crush main menu? So far I threw something together using Mathf.PingPong
[code]void Update () {
transform.localScale = new Vector3(Mathf.PingPong(Time.time, 3), Mathf.PingPong(Time.time, 3), Mathf.PingPong(Time.time, 3));
}[/code]
I recommend edy's vehicle physics, I know edy IRL and his code is awesome :V, except when he hasn't drunk cafe that day.
Garry, can you tell us a little about the networking in Rust? Did you guys use a specific library or?
It uses uLink. Everyone moans about it. But it uses NGUI and everyone moans about that too. And UniSky, and everyone moans about that too.
Sorry, you need to Log In to post a reply to this thread.