Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
I want to make a game that has portals in it, so whenever you left click you will get a blue portal and whenever you right click you will get an orange portal. I have made a specific sprite for the portals to spawn on (I want to be able to copy and move this sprite to other places where I want portals to be) but if you want the other portal there you can click and it will get replaced. I was thinking about using variables for this but am pretty clueless on how to do it properly.
Any help appreciated.
It it going to be like the game portal where you can shoot them? If thats the case, then I would recommend using a raycast to place the portal.
Yes,and what's a raycast?
A raycast can be used for many things.
Look here for more: https://www.construct.net/en/make-games/manuals/construct-3/behavior-reference/line-of-sight
In your case you would use a raycast to "cast" a "ray". The ray is basically a line from one point to another. Then its like you travel along this line. If you hit something then you know that the ray is intersected. You can then get the X and Y coordinates for that position, and place your portal there.
okay cool, can you post an example of what that would look like in my case, on the event sheet?
okay, ill try it out. thanks for all your help.
I've done that part, what's the other events that I would need to add to get the portal spawning on the coordinates, also some events to help with replacing an opposing portal when shooting at the spawner sprite .
You would use 'On ray intersected' -> spawn object (portal) at player.lineofsight.hitx, player.lineofsight.hity
Also I recommend adding the drawing canvas over your layout. Then draw a line from the start of the raycast to the point it hits something. This will make it easier to visualize the "ray".
this is my event sheet so far.
I don't know what to do now, I am pretty stuck.
the portal does not land at the desired location and I cannot get the drawing canvas function to work.
Do you mind posting your capx?
sure, how do i do that?
Develop games in your browser. Powerful, performant & highly capable.
Menu -> Project -> Save As -> Save as Single File
Then upload it to like google drive or something.
Then link to it here.
Here's the link: