• Unity3D - Discussion
    5,004 replies, posted
Okay I'm having the weirdest problem of my life. The code works sometimes though, so I don't understand what the fuck's going on. So, I have 6 inputs. MouseX, MouseY, Forward, Backward, Left, Right. I'm currently working on the simple character movement system. I'm having a fucking unexplainable bug, though. So Forward and Right both add momentum to the Z and X axis respectively. Backward and Left add negative force to the Z and X axis, again respectively. The issue is, when I first made pressing left move your avatar, it wouldn't work. But when you'd press the right input button, you'd go forward-right. I eventually fixed it by changing the way I was adding multiplying the variable Movespeed by Time.deltaTime. No idea why that fixed it but whatever. So I close Unity after that because I'm tired of its bullshit. So I start back up today, and I add the ability to move backwards. I'm running into the same god damn problem. Pressing S doesn't make you move backwards, but pressing D makes you move backwards-right. I can't fix it, but something weird is also going on. If I use the arrow keys (Which are the alternate positive keys for the movement buttons) it works fine. Every action performs correctly without a hitch. I have NO clue what the fuck is going on. Should I reinstall Unity?
Can you post the code?
GUI is driving me nuts. I'm really good with XAML and WPF, so I could write the UI I want for that here, if XAML and WPF were an option. But they aren't. I've tried the free version of NGUI, and I found that it was extremely finicky and far from the WYSIWYG that it's advertised as. Any idea how to make something like this: [IMG]http://puu.sh/alKDd/58e381fcb5.jpg[/IMG] Scalable and responsive? That's currently just a mockup, but you get the point - I want that to look just as good when scaled up and widescreen.
[QUOTE=Fourier;45459257]Just get free NGUI.. :) it is at 2.7.[/QUOTE] I bought Daikon on a super deal, this worth 35$, and this really worthed :v
I should set up a macro for this [vid]http://files.facepunch.com/garry/2014/July/22/1406019597.mp4[/vid]
[QUOTE=garry;45464147]I should set up a macro for this [vid]http://files.facepunch.com/garry/2014/July/22/1406019597.mp4[/vid][/QUOTE] No. \Unity\Editor\Data\Resources\ScriptTemplates\ Then edit the script how you want, thank me later :v: edit: Oh and regarding the auto formatting, just change it in the monodevelop settings. There are tricks to make it work even on newly "unity-generated" project files...
[QUOTE=Felheart;45464197]No. \Unity\Editor\Data\Resources\ScriptTemplates\ Then edit the script how you want, thank me later :v: edit: Oh and regarding the auto formatting, just change it in the monodevelop settings. There are tricks to make it work even on newly "unity-generated" project files...[/QUOTE]Fairly certain garry is using Visual Studio, that looks like it anyways :v:
[QUOTE=dije;45464210]Fairly certain garry is using Visual Studio, that looks like it anyways :v:[/QUOTE] The editor you use does not matter. Unity generates the file from the same template.
Okay, so I made a partial player and weapon base, it's just getting the events and getting everything set up for some actual coding, just need some tips, first one I have ever made, I am trying to make an event type system, so creating other weapons will be allot simpler and stuff. This is what I got, anyone got any suggestions? (The code isn't very long) [URL="http://pastebin.com/WSMQ8PfB"]BasePlayer[/URL] [URL="http://pastebin.com/baK5wGQS"]WeaponBase[/URL] [URL="http://pastebin.com/3M0PkKa9"]WeaponManager[/URL] < Gotta fix some events in here, I am thinking of just directly calling a function on the player like ply.OnWeaponLost() instead of making an event and invoking it, since all players will be the same. [URL="http://pastebin.com/e29nUWDK"]Example Pistol ("weapon_pistol")[/URL] Is there anyway I can make a global hooking system like Garry's Mod, the hooking system in Garry's Mod is fabulous, I wanna re-create it in Unity.
[QUOTE=Felheart;45464233]The editor you use does not matter. Unity generates the file from the same template.[/QUOTE]I was talking about the auto formatting, Visual Studio auto formats with curly braces on their own lines.
[QUOTE=AnonTakesOver;45464356]Okay, so I made a partial player and weapon base, it's just getting the events and getting everything set up for some actual coding, just need some tips, first one I have ever made, I am trying to make an event type system, so creating other weapons will be allot simpler and stuff. This is what I got, anyone got any suggestions? (The code isn't very long) [URL="http://pastebin.com/WSMQ8PfB"]BasePlayer[/URL] [URL="http://pastebin.com/baK5wGQS"]WeaponBase[/URL] [URL="http://pastebin.com/3M0PkKa9"]WeaponManager[/URL] < Gotta fix some events in here, I am thinking of just directly calling a function on the player like ply.OnWeaponLost() instead of making an event and invoking it, since all players will be the same. [URL="http://pastebin.com/e29nUWDK"]Example Pistol ("weapon_pistol")[/URL] Is there anyway I can make a global hooking system like Garry's Mod, the hooking system in Garry's Mod is fabulous, I wanna re-create it in Unity.[/QUOTE] Wont be as easy as in gmod since you dont have lua, but still "relatively" easy. But you can expose an interface IWeapon{} or something that other people can implement. Then you compile the files at runtime just like gmod does with lua_load. When you have the assembly you scan it for types that implement IWeapon, instantiate that, then cast it to IWeapon and you're good. If you don't want to implement everything you can also make the weapon classes themselves public and the functions virtual. So others can create new weapons that just inherit from existing base weapons. Another way (more like lua) would be to make the function delegates themselves directly public. so in your code do something like that: class MyGameManager { public delegate bool CanPlayerShootWeaponDelegate(Weapon w); public CanPlayerShootWeaponDelegate cpswFunction; static MyGameManager() { cpswFunction = MyDefault_CanPlayerShootWeaponFunction_Implementation; } } Then people can add your game as reference in VS and code stuff that changes functions in your engine... @dije: Oh I'm sorry I didn't get that. Yes by default it places them on new line, but I think you can change that behaviour. (Or was that option in Resharper!? I don't remember...)
[QUOTE=garry;45464147]I should set up a macro for this [vid]http://files.facepunch.com/garry/2014/July/22/1406019597.mp4[/vid][/QUOTE] From what I've seen I think you on about the template which can be changed. If I'm wrong sorry. [editline]22nd July 2014[/editline] Sorry, felheart already said it.
On monodevelop, where do I find the auto formatting? I hate how it auto indents my lines of code, along with placing all the curly brackets at the end of each line.
[QUOTE=garry;45464147]I should set up a macro for this [vid]http://files.facepunch.com/garry/2014/July/22/1406019597.mp4[/vid][/QUOTE] I just use Visual Studio 2010, when I open the script CTRL+A then CTRL+X and at last CTRL+V. It automatically "corrects" the brackets, doesn't remove the comments though.
[QUOTE=garry;45464147]I should set up a macro for this [vid]http://files.facepunch.com/garry/2014/July/22/1406019597.mp4[/vid][/QUOTE] I use vs2013 and I just ctrl+K, ctrl+D and then I just have to click-drag-delete the functions and comments.
Here's my script for explosion with pushback. [code]#pragma strict var explosion_magnitude : float; var explosion_rate : float; var explosion_speed : float; var current_radius : float; var explosion_radius : CircleCollider2D; var target : Vector2; var epicenter : Vector2; var direction : Vector2; function Start () { explosion_radius = GetComponent(CircleCollider2D); } function FixedUpdate () { if (current_radius < explosion_magnitude) { current_radius += explosion_rate; } else { Destroy (gameObject); } explosion_radius.radius = current_radius; } function OnTriggerEnter2D (other: Collider2D) { if (other.gameObject.rigidbody2D != null) { target = other.gameObject.transform.position; epicenter = gameObject.transform.position; direction = 1000 * (target - epicenter); other.gameObject.rigidbody2D.AddForce(direction); } }[/code] How exactly do I go about making the explosion ignore what it had already hit? Can't think of anything but tagging the other collider on hit and subsequently ignore all tagged colliders, which is not really feasible. EDIT: nvm obviously that's not the problem since it's OnTriggerEnter. I think I know what's the real issue
Hey, garry. I'm curious what you guys are doing for the UI in Rust. It's HTML based, right? Did you write your own framework or are you using something like PowerUI? I want to switch to something XAML-like for my UI, since NGUI and all are decent enough, but seem to largely favor absolute placement over relative. Although I am deliberating between buying the new NGUI to see if it solves my issues in its current free state, Daikon Forge looks rather tempting but seems to be a no-go if we want to release on mobile (and we do.)
It's [url]http://coherent-labs.com/overview/[/url] I think.
[QUOTE=Protocol7;45465703]Hey, garry. I'm curious what you guys are doing for the UI in Rust. It's HTML based, right? Did you write your own framework or are you using something like PowerUI? I want to switch to something XAML-like for my UI, since NGUI and all are decent enough, but seem to largely favor absolute placement over relative. Although I am deliberating between buying the new NGUI to see if it solves my issues in its current free state, Daikon Forge looks rather tempting but seems to be a no-go if we want to release on mobile (and we do.)[/QUOTE] Coherent UI I'm pretty sure - [url]http://coherent-labs.com/unity3d-pricing/[/url]
Live editing and debugging, data binding... Fuck, wish I had more money to spend. I suppose I need to ask myself if it's really worth buying NGUI/Daikon Forge with Unity 4.6 right around the corner.
[QUOTE=Protocol7;45465797]Live editing and debugging, data binding... Fuck, wish I had more money to spend. I suppose I need to ask myself if it's really worth buying NGUI/Daikon Forge with Unity 4.6 right around the corner.[/QUOTE] Well I bought NGUI 3 days ago.. 4.6 will still needs couple months...
I also bought NGUI. The paid version works way better than the free one. I think I can make it work.
[QUOTE=Protocol7;45467160]I also bought NGUI. The paid version works way better than the free one. I think I can make it work.[/QUOTE] Yeah, it's nice :).
NGUI is the shit. [t]http://i.imgur.com/9ON7bTy.png[/t] And I set out to do what I wanted to do: Make it resizable without issue. [t]http://i.imgur.com/HyQgjOS.png[/t] I'm happy, now.
Does anyone here use DFTween? How do I set the easing type?
Hello. One of the creators, here. You call SetEasing on your Tween object and pass an easing function. Like so: [code] myTween.SetEasing( TweenEasingFunctions.Whatever ); [/code] TweenEasingFunctions is a class with a bunch of static methods. Each method represents an easing type (which actually means you can write custom ease types, by the way :wink:), and you pass one of these methods to the SetEasing function.
The second playable area is pretty much done, coding time! [IMG_THUMB]https://dl.dropboxusercontent.com/u/33714868/term2/arena6.jpg[/IMG_THUMB]
Hello fp! So I started doing this game in Unity.. So far there is nothing but my shabby terrain skills, but I promise I will have gameplay to show in the future! [IMG]http://i59.tinypic.com/rii1js.png[/IMG]
Gonna use my pro trial soon. Any pro features I should check out?
[QUOTE=Luafox;45468033]Following along with the stealth game tutorial series made me realise I need to learn more math stuff. Other than that I learned a lot of cool things so that's good.[/QUOTE] I think this is what you will need from trigonometric functions most: - sin, - cos, - atan2 For Vectors - 3D vectors (x,y,z), - adding, - subtracting, - distance, - dot, - cross, - unit vectors For rotations - Euler, - Quaternion (you don't need to know, how quaternions work internally because it is clusterfuck, but you need to know, how to use them) Deltas - You need to learn delta stuff (&#916;), aka Time.deltatime (time difference from previous and current frame) [url]http://gafferongames.com/game-physics/fix-your-timestep/[/url] - others deltas that you will make them yourself/compute them yourself, like deltaPosition, deltaRotation, deltaColor, deltaHealth.. whatever Lerp - Interpolating stuff will be very common, so I recommend you to get familiar with linear interpolation (Lerp), - Inverse Lerp, - other interpolating functions
Sorry, you need to Log In to post a reply to this thread.