Hello,
I wanted to make an interesting game like the game Portal. But I have no clue how physics should work or how to code them. Can you guys please give some idea on the physics and how to code them?
Hello,
I wanted to make an interesting game like the game Portal. But I have no clue how physics should work or how to code them. Can you guys please give some idea on the physics and how to code them?
I’m not sure what you mean. Are you referring to real life physics? Or how that would interact with portals?
In the actual game Portal when a player goes through a portal their speed is conserved while their position is changed. The direction of their velocity depends on the normal of the portal.
The portals also have a lot of mechanics to do with puzzles, but those are pretty straightforward. If an object hits the portal it’s position changes. There are also lasers, which are a little more difficult. You could probably just use a raycast from the laser origin to see if it’s gonna hit a portal, then create a second laser object from the second portal.
Fyi when you ask a question if you’re more specific it is easier to help!
Oops, I’m very sorry DraftyScienceCoat75. I meant physics form the real portal game. I don’t play portal but I have a rough idea of how it works. Seeing how the real one conserves the speed of the player how can I do that in flowlab?
I have thought about uasing lasers to detect a portal but how would the game know what direction the player should go towards?
Well basically you would have to have a trigger for the event, such as a collision behavior. Then store the speed of the player (as a magnitude, so just run it through an absolute value expression). You could store it by using the ‘set’ in a number behavior, an object value, it a variable in an expression.
Then once change the players position, you could get the rotation of the second portal and use that and the speed you stored earlier to set the player’s new velocity.
I think I might as well make an example, so I’ll post that once I’m done
Ok, Thank you so much. This will help me a lot. I will try to create a test sample world to see how things work. Also, the example will be very much appreciated DraftyScienceCoat75 but if not it’s ok.
Alright the example is pretty much done. Right now it’ll be pretty hard to understand because I haven’t cleaned, organized, and notated the code yet. I have been working on it for a while so I’ll probably do that some other time, and I’ll let you know when I do. Right now it’s more of a proof of concept.
I’ve also realized sometimes the portals put you on the wrong side, but it’s not consistent so idk about that atm.
It’s ok I very much appreciate the help I’ll also start experimenting whit the physics.
Hello,
So today I was trying to recreate your code in my world but realized I can’t because of the bundles in each other. So is there a way I can create them or a way for you to send them to me?
you could copy the code and import it
Okay thank you so much
Hi DraftyScienceCoat75,
So I imported you code and did a little bit of tweaking of my game but for some reason the portal gun keeps spawning at the default location of (0,0). I’m not exactly sure what’s causing the problem I’ve checked multiple parts of the code but they seem to be normal. So can you please give me any tips on how to fix the issue?
Here’s the link to the game: https://flowlab.io/game/view/2193386
Ok thank you so much. I very much appreciate the help!