« first day (2663 days earlier)      last day (2354 days later) » 

7:59 AM
7
Q: How do I integrate bullet physics into my game?

SirYakalotI downloaded the release file found here, but I'm just not sure where to start. In my game I have a number of oblongs and a sphere, I want all of these to collide with one another. (They all have meshes and associated bounding volumes) edit - I just realised the cuboids actually have AABB's asso...

Very good answer!
 
 
6 hours later…
2:15 PM
Hey
 
user92578
hi
 
Do anyone know how can I restart my game? Like I can't make my game too long, so I want once it reaches the end, and then it should start automatically from the start, and the player shouldn't know that it restarted
 
user92578
What? Surely after N iterations the player will recognize the cycle
 
user92578
Again, since we know nothing about your game, this is a hard question to answer.
 
user92578
Are you looking for a design solution or a restart implementation?
 
2:18 PM
I mean like in subway surfer the game keeps going, so I want the same thing, bc I can't make it too long, so I want it to somehow start from starting once it reaches the end.
@Tyyppi_77 I think restart
 
user92578
subway surfer generates the levels randomly
 
user92578
so there's no restart in subway surfer
 
Randomly? Like what?
 
user92578
It uses procedural world generation to place the obstacles
 
What's that?
 
user92578
2:19 PM
No one has manually placed the trains and ramps and fences in the level
 
Yeah
 
user92578
They use a randomized algorithm the place the obstacles
 
user92578
Which means that they don't have to loop/restart the level after a certain distance, since they can just randomly place more and more obstacles
 
Yeah, but I also randomly placed it earlier, but it kinda got messed up. So again I had to place it by myself.
@Tyyppi_77 Yeah, I got it.
But isn't there any other way to do that?
 
user92578
Nov 15 at 11:59, by Hemlata
Bc it's easy to do
 
user92578
2:20 PM
@Hemlata Any other way to do what?
 
@Tyyppi_77 Haha yeah, but when I kept playing it, I realized, it's not that easy haha
@Tyyppi_77 I mean any other way to start the game from starting, since I can't make the game very long by myself.
 
user92578
I can't answer that since I don't know what your game is.
 
So once it reaches at end I want it to somehow start from the starting, so the player can keep playing
@Tyyppi_77 It's same as subway urfer
surfer*
Endless runner game
 
user92578
You've several times told me that it's not like subway surfer
 
user92578
Nov 15 at 12:13, by Hemlata
@Tyyppi_77 Nah, if I increase the player speed it's hard to play and by endless runner I mean my player moves automatically but it's totally different from endless runner. It's not even close to endless runner
 
2:23 PM
@Tyyppi_77 Yeah, of course, it's not exactly same like it, but it's like endless runner
Player keeps running forward
 
user92578
it's totally different from endless runner. It's not even close to endless runner
 
@Tyyppi_77 Yeah, by that I mean, it doesn't have those trains and all that stuff
 
user92578
trains aren't specific to endless running
 
user92578
endlessly running is specific to endless runners
 
Yeah lol
 
user92578
2:24 PM
so how the f does "not even close to endless runner" end up meaning "no trains"
 
@Tyyppi_77 Well endless runner means in which player keeps moving forward automatically, so that's what my game is doing, hence endless runner.
 
user92578
"it's totally different from endless runner. It's not even close to endless runner"
 
user92578
so actually it's totally an endless runner
 
user92578
it's incredibly close to an endless runner, since it's an endless runner?
 
@Tyyppi_77 Well, I accidentally said that, but I mean it's not like subway surfer which has trains and other stuff
@Tyyppi_77 Awe yeah haha
 
2:26 PM
Can you specify, do you want the game to cut back to the beginning and reset the player's score / etc, like starting the level from scratch? Or do you just want the obstacles to keep looping in a single continuous play?
 
@DMGregory I want the obstacles to keep looping in a single continuous play
 
user92578
This depends on how your world is generated currently but you could just pop the players position back to the start once it reaches the end
 
user92578
player.Z = player.Z % levelLength;
 
LevelLength?
 
user92578
You might also have to render a second copy of the start of the world to keep the rendering working too
 
2:28 PM
Are your obstacles all pre-placed in your scene, and your player moves forward through them? Or do you spawn any of the level content at runtime?
 
user92578
yes it's the length of the level.
 
@DMGregory They are already placed in my scene and yeah player moves forward through them
 
Is your camera attached to your player, or does it have a follow script or its own movement script?
 
My camera is attached to the player and it has a follow script too
  public Transform player;
    public Vector3 offset;

	// Update is called once per frame
	void Update () {
        transform.position = player.position + offset;
	}
That's my follow script
 
Ah, that'll probably work fine with Tyyppi_77's proposal. You might need to move that from Update to LateUpdate if you find the player disappears for a frame when they wrap around. (Because the camera followed their last position, before they teleported back)
 
2:33 PM
How should I do that?
 
user92578
5 mins ago, by Tyyppi_77
player.Z = player.Z % levelLength;
 
Oh yeah haha
 
user92578
This assumes that the player runs Z forward
 
Should I add that in LateUpdate method of follow script?
 
user92578
It needs to warp the player's position so it should probably go to the movement script
 
2:36 PM
How are you moving your player forward currently?
 
transform.Translate(userDirection * speed * 12f * Time.deltaTime);
Like this
 
Then Tyyppi_77's modulo line can go immediately after that one.
 
@Tyyppi_77 So I should add it in fixedUpdate() method of movement script, right?
Yeah, I will try it
 
user92578
I don't know anything about the different update-functions, but yeah, probably after that line
 
And instead of player, I should write transform.z, right?
 
2:38 PM
transform.position.z
 
Ok, I will try it.
 
user92578
And I'm not sure if C# operates floats with % so you might have to use fmod there
 
If it gives you grief about assigning just one member of a struct you might need to copy to a local first, a la...
 
Yeah
But I didn't get still what's a level length haha
 
Think about it
 
user92578
2:40 PM
^
 
You want to put the player back to the start at the end of the level
 
Like If I have a plane on which player run, then the length of that plane
?
 
For instance
 
var position = transform.position;
position.z %= TheActualWorldspaceLengthFromTheStartOfYourLevelToTheEnd;
transform.position = position;
 
@DMGregory Nice variable names there. Comments are for losers
 
2:41 PM
Um, yeah.
 
Note that this assumes your "start" is at zero. ;)
 
Yeah haha
 
user92578
Ah nice, C# is okay with floats in modulus
 
Yep
 
Another approach you can try is to place a transform where your player should start, and another one (maybe a trigger volume) at the place where they should wrap around, and then use the spacing between those two objects so you don't have to measure it manually.
 
2:44 PM
Yeah, I will try it
 
@Bálint I figure when terse names are apparently too ambiguous, err on the side of way too verbose and self-explanatory. ;)
 
3:01 PM
Like it start from 0 and end at 1000, so I write position.z %= 1000?
brb
 
user92578
yes
 
user92578
I should've probably asked if you know how modular arithmetic works?
 
3:36 PM
@Tyyppi_77 Yeah I know. Like 10 % 2 = 0 haha
 
user92578
terrible example but good
 
Like it gives the remainder
haha
So should I write like I said? position.z %= 1000?
 
user92578
if the world is 1000 units long, then yes
 
Yeah.
I will try it
Lol you're younger than me but you are very smart haha. I feel like I know nothing lol
 
user92578
you'll learn
 
3:44 PM
Lol yeah, I am almost 21, but I really know nothing haha, but people of my age know a lot. But yeah, If I will work hard then I can be also good at programming.
 
user92578
I didn't know a whole lot when I started working on my game, but I've learned a ton during the past three years or so
 
Yeah
Do you just self study?
 
user92578
yup
 
Nice.
 float position = transform.position;
            position.z %= 1000;
            transform.position = position;
What kind of variable should I use of position?
 
user92578
3:48 PM
that or var if you don't really care
 
user92578
I'm working on a website for a friend and Chrome is giving me a hard time with height 100% elements
 
Aww it's working :D
 
user92578
nice!
 
@Tyyppi_77 With height?
Thanks a lot! :)
 
user92578
elements that are supposed to take the whole screen in height
 
user92578
3:51 PM
It breaks at smaller screen sizes for some reason, works fine in FF
 
Yeah
I have also made a website, but I made a clone of whatsapp website, just for practice.
 
user92578
cool
 
But It was not compatible with different screen size
 
user92578
yeah it's actually been a while since I've done mobile layout stuff
 
Yeah.
 
user92578
3:52 PM
I made a website for our comp sci freshman party a few weeks ago, but there was two of us on the website team and the other guy handled the mobile port
 
But I will have to again start with HTML and CSS, bc I will need to build a website for my game
@Tyyppi_77 Oh that's nice
 
user92578
it was a small enough responsibility that I was able to handle but I also get a freshman point for working on the party
 
user92578
We need to collect freshman points to get our college caps in the spring
 
Yeah that's cool
I wanna add gems in my game, so people can buy. Do you know which language I should learn for it?
 
user92578
language?
 
3:56 PM
I mean programming language
 
user92578
What's wrong with C#?
 
Can it do like let people buy stuff, do transaction of the money and all?
 
user92578
That's not a feature of the programming language, it's a feature of the engine
 
user92578
Or rather, you can do that stuff in pretty much any programming language
 
Yeah
that means I can do that in C# too?
 
user92578
3:58 PM
Yes.
 
Oh that's nice
 
user92578
You can do everything that's possible in Unity in C#
 
Yeah.
 
user92578
Anyways I'll head to sauna.
 
user92578
bbl
 
3:59 PM
Sure.
Later!
 
 
3 hours later…
6:38 PM
I found that my creativity for shot composition and scene editing opens up after the first beer, peeks at the 3rd..
 
You found the artistic Ballmer point.
 
now all that is left is for someone to post the XKCD about it
 
aaaand the spider is still in my screen ... It should be dead of dehydration by now. Starting to think it's made its home and goes out at night to feed.
 
@UriPopov Don't worry, got you covered
 
(y)
 
 
1 hour later…
7:55 PM
There's so many things I want to refactor in my engine now that I've started using C++11 features. Things that I wrote before compilers in console SDKs were anywhere near C++11 "capable".
But I also want to get somewhere and finish a game first...
And one thing in particular that is not even original C++ compliant but works on all compilers and probably always will because it makes no sense otherwise... (It relies on testing this pointer for being null which technically isn't legal C++)
But it's sooooo convenient.
eg: object->GetRootObject() // checks and returns null if object is null without crashing.
It doesn't sound right in terms of OOP principles but it's so convenient when doing UI code. Skips a whole bunch of if-null checks and you can check just the final result.

Other languages (mostly scripting) essentially have that feature built-in.
 
8:12 PM
ahh the good old ?. operator
 
auto r1 = object ? object->GetRootObject() : 0;
auto r2 = r1 ? r1->FindObject("title") : 0;
auto r3 = r2 ? r2->FindGraphicLayer("Text") : 0;
if(r3){
r3->SetText(new_text);
}
vs
object->GetRootObject()->FindObject("title")->FindGraphicLayer("Text")->SetText(new_text);
 
doesn't seem that high-priority to fix
if you wanted you could hack it in by overriding operator ->
 
But that demands creating smart-ish pointer just for this when a regular pointer could do :P
 
true
 
I know there are work-arounds, it's just that this is created because they decided to word it as " this can't be null, ever".. when in fact it can, sort-of.
 
8:23 PM
well I think it makes the rest of the language design easier
because then you don't have to think about corner cases like "when is . not available but -> is"
 
Doesn't change much. the only thing it changes is that the compilers completely removes checks for `if(this == 0)`
You can still create null references even if the language doesn't "allow" it.
but you can't even check for them in debug and print some smarter debug info context than the debugger can...
 
oh yeah, I guess Foo &bar = *((Foo *)0) is still a thing
 
And removing if(this == 0) is the only optimization the compiler does with this rule.
Which is dumb because the only time you'd check for this is when you know the code is crashing and want to do something smarter to track down the issue or try to keep going in the release build. (EG: the player found a way to spawn way too many of something or sequence-break press a button when they shouldn't be able...).
Or want to do something convenient.
I haven't found a good optimization case for the compiler to eliminate the this==null checks completely. Normal compiler-generated code doesn't check for null to start with so it's not like it's removing and performance hogs.
Nothing in C++ implicitly checks for null pointers. It's all explicit or KABOOM! null-pointer access.

<*rage face*>
I think that bugs me more than the lack of % operator for floats/doubles when fmod() exists and is required as part of the c99 standard but the operator still produces a compiler error.
 
8:48 PM
While we're at it, I wish % was like python where -5 % 2 == 1
makes grid-wrapping code a lot cleaner
 
yeah
But the rule is that (-5 % 2) + (-5 / 2) * 2 == -5
So it needs to return -1
 
Haskell solves this problem by having two division operations quot and div, one paired with mod and one paired with remainder
python solves this by saying "integer division always floors instead of truncates"
 
So many solutions but C just says: NO MODULO FOR YOU!
 
well, I wouldn't want to be the guy who goes to the C++ committee and says "hey lets break 40 years of programs by changing the semantics of division"
 
yeah, but mapping % to fmod wouldn't break anything since it was always an error.
And then 10,000s of people could throw out their Modulo(a, b) templates they had to create just to work around this.
 
9:00 PM
just write your own language with a sane % operator ¯\_(ツ)_/¯
 
I'll call it C++17+%
 
it'll get stuck in limbo and come out in the next decade, better just call it C++2x+% to be safe
 
9:35 PM
UGH! Xlib has a #define Status int in its headers ...
So it messed up struct Status {...} in one of my classes after I included the X11 headers.
 
 
1 hour later…
11:01 PM
hey unity is almost done.. look at it. It's just the fist reflection probe :(
 
11:19 PM
ouch
 
11:33 PM
oh no it's ot turns out half the static geometry was to set to static so now I'm baking again. I'm getting so baked dude lol
 

« first day (2663 days earlier)      last day (2354 days later) »