Iwamoto: I’m currently only affecting the value that exceeds itself, so only x is affected by width; should this be affecting y as well, or rather, the angle that they collide into to the side with?
Kimple: I could explain it better
Kaatz: The point ha, well, hmm. The thing is part of this is taken from a tutorial and I’ve kinda messed about a bit just trying it out for the sake of it I guess
Sylve: So somethings in there probably seem out of place
Perschall: And given the fact I probably wouldn’t design things in place anyway, this is the result ta dah
Kimple: This code is common for small projects but for anything real you need to fix the collision
Kimple: The basic issue is that
Kimple: You’re not detecting the collision until after the fact
Skilling: What the collision should be pre-emptive?
Kimple: So, among other things, if something were to move fast enoguh, they could move through something not so much here, since your wall are solid and extend to infinity
Kimple: You have the ‘other things’ problem
Kimple: Where some things are further into the wall
Kimple: When you do the reflection
Neurohr: What so some of the objects could be reflecting at width + 1 and some at width + 2 for example?
Flournay: That seems inevitable though. I guess I could reset the value
Kimple: There are two methods
Kimple: 1: continuous detection
Kimple: Basically you do a raycast to detect whether or not you’ll collide
Kimple: And then solve for the collision point
Kimple: 2: discrete detection, which is more common
Sams: 1 – what so constantly eval how far an object is from the reflection point?
Kimple: Basically instead of moving an object by vel
Kimple: You split vel up into a bunch of chunks
Kimple: And move it by a little bit each time.
Seemer: What so velocity would be an array say velX = 0.1, 0.1, 0.1, 0.1 ?
Kimple: You usually just divide vel by a number
Kimple: And modify it each time
Kimple: I’d show you with your code
Kimple: But it’s kind of weird
Kimple: So here’s some code i have that does it
Kimple: Http://pastie.org/10402055 is probably the closest to what you have there
Zachry: Ace I’ll have a look at it it always trys to autocomplete to Potaczala on here for some reason
Arters: Ah it’s another user, cool cool.
Kimple: So the thing is for this to be perfect you probably will need continuous detection
Kimple: Which isn’t that hard for *****
Kimple: But i don’t have code around since i’ve only done it once or twice
Kimple: On the bright side perfect collisions aren’t a thing in the real world either
Ruiz: Perfect – I guess perfect collisions might be needed for any kind of geometric animation?
Kimple: If you are willing to tweak your points you could have it be perfect
Kimple: Just make sure it starts and moves so that when it hits they’ll all be at the same spot when they reflect
Kimple: Generally though i wouldn’t recomend this kind of simulation for this though
Kimple: I’d say you’d probably want to compute how far in y you need to move to be perfectly on the edge
Kimple: Interpolate that much each frame
Slaney: Probably a bit above me at the mo
Kimple: I’d try what i suggested and just multiply that accuracy by something like 20
Kimple: The code i pasted. do you think you could do something like that
Kimple: Where i said // multiply this by something for more accuracy
Kimple: If this is the number you have on the screen at a time, 20 or 30 would be fine