Rigid body physics help using GML
#1
Posted 01 September 2012 - 11:19 AM
Thanks in advance
#2
Posted 01 September 2012 - 02:59 PM
Currently this doesn't qualify for the Advanced GML Discussion forum.
#3
Posted 01 September 2012 - 05:53 PM
#4
Posted 01 September 2012 - 08:09 PM
I tried understanding collisions between two rigid bodies, using vectors and collisions points, but I dont understand, explain me please.
I would say you should take a look at the "Extrem Physics dll", Are you good with gml? or do you work with the d&d functions?
Edited by fantastichumore, 01 September 2012 - 08:10 PM.
#5
Posted 01 September 2012 - 08:52 PM
Thanks in advance
#6
Posted 02 September 2012 - 10:20 AM
You are going to need to understand vector math already, or at least the notations of the vector operations and how to write the vector math in x,y,z components, and use some scripts for those operations if you can't write them yourself.
You'll also need to understand what a surface normal means and how to detect it in the point of collision (as well as that point itself).
If you don't, you will not be able to figure this out yourself using only gml, and no one is going to write all the codes for you, either (as a rule of thumb you should minimize the amount of code that you don't understand in your projects, anyway). The theory of rigid body physics is built upon the framework of higher level math (such as vectors), so explaining its principles from the foundations of the math used would take months of work.
#7
Posted 02 September 2012 - 01:03 PM
#8
Posted 02 September 2012 - 02:07 PM
That is also covered in the link.
#9
Posted 02 September 2012 - 03:04 PM
#10
Posted 02 September 2012 - 03:06 PM
#11
Posted 02 September 2012 - 03:12 PM
#12
Posted 02 September 2012 - 03:35 PM
You can also google point inside rotated rectangle.
#13
Posted 02 September 2012 - 04:26 PM
pointx = (box1.x+box2.x)/2 //collision point x
pointy = (box1.y+box2.y)/2 //collision point y
if ((pointx) && (pointy))){
show_message("there is a collision")//meaning there is a collision
}
my code is right, right?
#14
Posted 02 September 2012 - 05:54 PM
No..my code is right, right?
The code goes to show that you are not going to be able to code a physics engine. You'll first have to learn the basics of programming, sorry.
For example, pointx is a coordinate (a double), not a truth value.
#15
Posted 02 September 2012 - 06:17 PM
#16
Posted 03 September 2012 - 02:41 PM
#17
Posted 03 September 2012 - 03:09 PM
You are doing an if statement on numbers (they are called doubles because that's what game maker uses.).
The if will never return true, because numbers can't be true. (Unless they are both 1.. but that's very unlikely)
I think Tepi's right, maybe you should brush up on GML before you try to write a physics engine.
#18
Posted 03 September 2012 - 03:14 PM
In GML, as in many other programming languages, the structure of an if-statement is the following: if (<condition>) <statement>;. The condition has to evaluate to values false or true (logically). Truth values like this can be derived from conditions constructed by comparisons (some value) C (other value), where C represents '==' (or '='), '>', '<', '>=', or '<='. Conditions can be connected by logical connectives such as '&&' (or 'and'), or '||' (or 'or'). In many cases, you can even interpret the if-statement in natural language. A condition is logical only if it evaluates to true or false.
Now in your code you use "(pointx) && (pointy)" as a condition, but pointx and pointy are not conditions, since they evaluate to the coordinates of the point between the boxes, which is never (or, very rarely) false or true. If the point (pointx,pointy) happened to be (1.23, -7.6), then your if-statement would read "if 1.23 and -7.6, then do something", which doesn't sound very logical.
EDIT: Looks like SapperEngineer was faster than me.
Edited by Tepi, 03 September 2012 - 03:15 PM.
#19
Posted 03 September 2012 - 06:41 PM
#20
Posted 18 September 2012 - 07:50 AM
if object1.x>=object2.x && object1.x <= object2.x+object2.sprite_width && object1.y = object2.y {
return true
}else if object1.x<=object2.x && object1.x >= object2.x-object2.sprite_width && object1.y = object2.y {
return true
}else if object1.y>=object2.y && object1.y <= object2.y+object2.sprite_height && object1.x >= object2.x && object1.x<=object2.x+object2.sprite_width {
return true
}else if object1.y<=object2.y && object1.y >= object2.y-object2.sprite_height && object1.x >= object2.x && object1.x<=object2.x+object2.sprite_width {
return true
}else if object1.y>=object2.y && object1.y <= object2.y+object2.sprite_height && object1.x <= object2.x && object1.x>=object2.x-object2.sprite_width {
return true
}else if object1.y<=object2.y && object1.y >= object2.y-object2.sprite_height && object1.x <= object2.x && object1.x>=object2.x-object2.sprite_width {
return true
}else{
return false
}
Edited by cj sniper 98, 25 September 2012 - 07:24 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











