Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411632 Posts in 69393 Topics- by 58447 Members - Latest Member: sinsofsven

May 12, 2024, 09:08:03 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General thread for quick questions
Pages: 1 ... 22 23 [24] 25 26 ... 69
Print
Author Topic: General thread for quick questions  (Read 136108 times)
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #460 on: December 27, 2015, 04:30:11 PM »

How do I update the graphic drivers on a surface pro 3 with windows 10?
Logged

indie11
Level 2
**


View Profile
« Reply #461 on: January 02, 2016, 11:46:57 PM »



Figure 1 shows the hero moving in the direction of the arrow. When it hits the obstacle... I want him to face the direction shown in figure 2.. how can this be done in unity's 2D system? I know this has something to do with normal but I am just not good at vector mathematics..

Logged

Oats
Level 1
*


High starch content.


View Profile
« Reply #462 on: January 03, 2016, 12:16:51 AM »

@indie11 I don't use unity so I have no idea how to implement it exactly, but what you want is the normal of the edge your character collided with, your characters "up" is then the direction the normal points in. Alternatively a super lazy option is assuming your shapes are convex your characters up can just be the direction between the shape your character is landed on's centre of gravity to your character's centre of gravity, but that will probably look a little weird if your shapes aren't almost circular, so the normal would be better.  Hand Thumbs Up Right
Logged

eh
Grhyll
Level 2
**



View Profile WWW
« Reply #463 on: January 03, 2016, 02:57:50 AM »

@indie11 For an answer specific to Unity and its 2D system, if you use non-trigger collisions, in the callback you should have a Collision2D object. There is a "contacts" attribute which should have at least one element, and this element has a "normal" attribute, which is a Vector2D giving you the direction you are looking for.
Logged

Programmer at The Game Bakers
3-50.net
Current project: oQo
Zorg
Level 9
****



View Profile
« Reply #464 on: January 03, 2016, 03:41:49 AM »

Additionally to Oats and Grhyll:
Collision2D has a 'point' attribute, too, which might be useful to set the player position on impact.
Code:
void OnCollisionEnter2D(Collision2D coll) {
p = coll.contacts[0].point; // collision point (vector2)
n = coll.contacts[0].normal; // collision normal (vector2)
angle = Mathf.Atan2 (n.y, n.x); // collision angle (float, rad)
angle360 = angle / Mathf.PI * 180f; // equal to angle * Mathf.Rad2Deg (float, eulerangles)
// set player position according to p and angle/angle360
}
(I was too lazy to initialize the variables, you'll have to do it somewhere first.)
« Last Edit: January 03, 2016, 03:50:01 AM by zorg » Logged
indie11
Level 2
**


View Profile
« Reply #465 on: January 03, 2016, 10:02:09 AM »

Thanks for the replies Oats,Grhyll and zorg.

I am currently using the raycast2d hit normal to set the angle and its working perfectly.. currently stuck at setting player's position.. Gonna work on it for a while..will use the 2D physics approach if this raycast system fails.
Logged

johanbrodd
Level 0
**


View Profile
« Reply #466 on: January 03, 2016, 08:15:02 PM »

Here's something I'm struggling with at the moment in Unity 5.3:

How do one on in 3D collision or trigger detect if an object intersects another, then restarting the current level? Then how do you check for this happening ever and always?

Thanks in advance.
Logged

JoBro Media on SlideDB:

Zorg
Level 9
****



View Profile
« Reply #467 on: January 04, 2016, 01:28:13 AM »

Code:
void OnCollisionEnter(Collision collision) { // put this script on the first object, for example the player
if (collision.gameObject.tag == "spikes") { // set "spikes" tag to spikes objects first, or nothing will happen
Debug.Log("Restart caused by spikes");
Application.LoadLevel(Application.loadedLevel); // load current level, old version without SceneManager
//SceneManager.SetActiveScene(SceneManager.GetActiveScene().name); // could work. did not use it, yet.
//SceneManager.LoadScene (SceneManager.GetActiveScene().name); // or likely this?
}
}

You'll find documentation and examples in the Scripting API: http://docs.unity3d.com/ScriptReference/index.html
http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

« Last Edit: January 04, 2016, 01:39:06 AM by zorg » Logged
johanbrodd
Level 0
**


View Profile
« Reply #468 on: January 04, 2016, 11:12:30 AM »

That sorted things out for me for sure. How do you in C# store variables in a global place, so the variables get loaded upon level reload? Is it with static variables? I'm not very good at C#. Thanks in advance.
Logged

JoBro Media on SlideDB:

Zorg
Level 9
****



View Profile
« Reply #469 on: January 04, 2016, 12:10:36 PM »

You could search for unity gamemanager tutorials which use singletons.
Here is an official tutorial, but i have no idea if it's up to date:
https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/writing-game-manager
Logged
oahda
Level 10
*****



View Profile
« Reply #470 on: January 24, 2016, 05:05:58 AM »

I'm confused as to when the GPU is "optimised for performing calculations" and when it is not. Working with linear algebra using the built-in types of, say, GLSL seems to be fast, but writing little trigonometry functions, like checking for line intersections, or whether triangles overlap, or checking bounding boxes, seems to be quite slow. Why? Is this faster on the CPU?
Logged

J-Snake
Level 10
*****


A fool with a tool is still a fool.


View Profile WWW
« Reply #471 on: January 24, 2016, 05:24:17 AM »

Princessa, just keep in mind that gpus are very bad at branching.
Logged

Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality.<br /><br />Trap Them: http://store.steampowered.com/app/375930
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #472 on: January 24, 2016, 05:37:14 AM »

Gpu is a lot of dumb cpu working at the same time on the same operation, quantity trump quality and that's fine for shader most of the time. But they all do the same things (program) at the same time. When you do a branch, it actually execute both path and discard the bad one. Also if one unit is slows it slow all the other units. It's great for batching uniform data, less so if you have exception in that data (branch) that create local complexity.

Cpu is a small number of core, quality over quantity. When you a branch you skip one path for the other.
Logged

oahda
Level 10
*****



View Profile
« Reply #473 on: January 24, 2016, 05:46:15 AM »

Yeah, I've noticed the branching problem before but I never knew why. Oh, well. I'll play around and see how much I can move to the CPU and pass as precalculated uniforms.
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #474 on: January 24, 2016, 07:02:35 AM »

Yeah, they suck at branching (and the main reason why we won't see GPUs ever replacing CPUs regardless of what doomsday naysayers say). More especifically, there's a single instruction decoder for all the threads, so if they don't all agree on a branch, both sides of the branch have to be executed. Ouch. (some weaker GPUs are even worse and have to do both always, older ones even having to go as far as simulating it through blending)

As for trigonometric functions: they are still slow. I was looking at some AMD docs some time ago, a GPU thread will perform four simple operations (like add or multiply) and one complex operation (like square root) simultaneously. Guess to which of those trigonometric functions belong. (on the flipside, this means you can be doing a vector operation at the same time)
Logged
oahda
Level 10
*****



View Profile
« Reply #475 on: January 24, 2016, 01:24:17 PM »

I wonder what I'm doing wrong in general tho. I see these old games, on old hardware like the GameCube, or just old PC's, that still manage to run complex 3D scenes with lots of effects with good performance while my 2D game on a much more modern PC slows down after just a few layers of effects.
Logged

Polly
Level 6
*



View Profile
« Reply #476 on: January 24, 2016, 02:31:45 PM »

I wonder what I'm doing wrong in general tho. I see these old games, on old hardware like the GameCube, or just old PC's, that still manage to run complex 3D scenes with lots of effects with good performance while my 2D game on a much more modern PC slows down after just a few layers of effects.

If by "effects" you mean kernel-style multi-pass fragment shaders .. then it's probably ( partly ) that. The fact that HD is the standard these days doesn't help either ( for those kind of shaders ).

+ In comparison, the vast majority of GameCube games uses a resolution of 640x528 ( 337920 pixels ).
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #477 on: January 24, 2016, 02:32:16 PM »

@princessa
Well the effects you are using are much less hacks than they did, also they are much less sophisticate that you give them credit for.
Logged

oahda
Level 10
*****



View Profile
« Reply #478 on: January 24, 2016, 04:45:34 PM »

I wonder what I'm doing wrong in general tho. I see these old games, on old hardware like the GameCube, or just old PC's, that still manage to run complex 3D scenes with lots of effects with good performance while my 2D game on a much more modern PC slows down after just a few layers of effects.

If by "effects" you mean kernel-style multi-pass fragment shaders .. then it's probably ( partly ) that. The fact that HD is the standard these days doesn't help either ( for those kind of shaders ).

+ In comparison, the vast majority of GameCube games uses a resolution of 640x528 ( 337920 pixels ).
Sure, but since it's not just higher resolution, but also better hardware, shouldn't the PC manage GCN prestanda at a higher resolution if the code is good enough?

@princessa
Well the effects you are using are much less hacks than they did, also they are much less sophisticate that you give them credit for.

Well, I've got nothing against "hacks" if the look fine and perform better...
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #479 on: January 24, 2016, 05:18:30 PM »

I made a thread about those when I find them (missing some new I should document) plus graphic paper and techniques

https://forums.tigsource.com/index.php?topic=32227.0

here is a blog dedicated to visual hacks in gaming
http://simonschreibt.de/game-art-tricks/

tell me which hacks you are looking for and I see if I have pointer about them
Logged

Pages: 1 ... 22 23 [24] 25 26 ... 69
Print
Jump to:  

Theme orange-lt created by panic