yeah, and having a more complicated system also means the players will have a harder time understanding it. so keeping it simple is always really good than making something controllable but hard to understand. As I said the way it is now is fine.
yes, I have been trying to do this too but im stuck on trying to spawn the player from another scene to the current scene. I know I could just simply copy and paste the player to each scene but that breaks the code because it adds .00# to it. im trying to mess around with an empty that on scene start spawn the player. but I don’t know how to get the player from another scene. I also tried to instance the player but it just kills the camera. maybe you have more knowledge on this. with Godot it was easy but I don’t know if upgbe even allows this.
yeah, some of the maps have indoors areas to add a save zone of some sort. I never told you what my project was about, now did I? I feel a little dumb now… Right the point is to have a multiplayer area like map where the players will have abilities like pull, pushing, and at this point thanks to my gravity god musikai the ability to also remove or add gravity to the enemy players to make it harder for them. the player will also have ways to prevent themself from getting knocked off the map with fuel jetpack, grappling hooks, or one that I can’t wait to create a weapon that switches places with the enemy that tried to knock you off. It’s kinda like gang beasts but without the ragdoll.
the concept takes place in a sci-fi galaxy where the maps are on different types of planets. like this map im making right now is on a gas giant planet and the platform is a gas depot nearing the planet’s outer layer where space starts. it harvests the gases of the planet and then ships it to other planets. I also have plans for a Chthonian Planet, a Rogue Planet, and a Pulsar Planet to name a few.
sorry if I left you wondering all this time about my project.
Wow! This will be huge project and you have a lot of cool ideas for gameplay! (I better don’t tell you how much work and bug fixing my simple game was where Marble and Ball only ware ableto roll. )
It’s really funny how this project makes me look into things that I also wanted but don’t work ‘out of the box’.
As I tried now, changing scenes does work when you make a linked copy when creating a new scene.(Don’t know if there is another way to create / import linked copies of Objects.)
Then only the Camera python module quits but now I know how to fix this.
So some Objects like Player and Camera System will be the same in every scene and on initiation we just spawn the player to spawn_target 0.
I could make a minimal template blend with only the necessary objects (without all the demonstration stuff) for easy linked instancing.
oh, I am well aware of how crazy it gets, that’s why I picked the easiest and less ambitious one that I have come up with although it has gotten more ambitious after all the awesome code that you have worked so hard on. I have 12 game wishes that I have hoped on making and have planned it all out but never started and over 15 games that I have given up on due to finding out how impossible they really are. the good thing is that I have promised my self that ill get them done even if it takes me my whole life which it might well, or I might get the developer lottery and one of these projects blows up and I get a company up and running but im not really thinking of that because it’s not healthy. all I can say is that I have set myself up for all the headaches and long nights. if only I could just not have work to do I would have spent every minute making my games but I don’t have that privilege. even game developers need to eat.
hm, I wonder if you fixed the camera not working with linked copies. maybe it will also work if I instance the player instead. there’s is only one way to find out.
I mean I was using the download file as a library of everything you added. I literally have almost all your updated files. but if it’s easier to do a template blend then do that.
Now the (updated) file is more organized. The important stuff is all in Collection “GameSystem”.
How to use this in a new file:
(delete any camera)
- append the Collection "GameSystem"
How to use link to new scenes:
in the scenes outliner select the new scene
then right click on the Collection "GameSystem" and choose "link to scene"
Added a Scene loader to the Spawn system (was only 1 line ) Objects with string property "load_scene" and a Scene name will load the Scene on Collision.
demo (other scene not included in actual file):
At first Blender crashed when changing scenes. It seems to me that it had something to do what Object was selected. Can’t say exactly. aha, perhaps: Make sure that in every scene the view is set to active camera (numpad-0).
ok, now im dying to know how you did this because this has been eating me away for days now. was it really that simple?! God, I really need to start learning more about properties and how to make them work. it seems that they are way more important than python alone.
Definitely!!!
Everything is controlled by object properties here in this System.
I made it so you can easily assign different behaviour or functions to objects the Ball is in contact with.
New:
Objects with string property “load_blend” and a file name (e.g.: other.blend) will load the blend on Collision (put the the blend file in the same directory)
is it passable to also load an object from a different blend into the current one once the player collides with the property object? for example, the ball hits a trap and 5 enemies get loaded in from a different blend.file. if this is possible it will save a ton on the engine lag by not having everything in the same blend.file. I was worried knowing that after having at least two detail maps on the same blend.file blender wouldn’t let me do anything more from all the lag it would have caused.
Hi,
welcome in the “performance” fight.
I don’t know if it is any help to load objects from another file but I looked into this foreign field and post some code below (after stepping in all traps that where on the road).
For performance here are my findings:
If the rasterizer is the main problem it helped to hide entire collections until needed.
if the depsgraph is the main problem it helped to join lots of small objects into a bigger one.
using the normal “add object” command in UPBGE always gives a short stutter (fps hit) that really is annoying in smooth gamplay. (so one better replaces this with an object pool, means objects are already somewhere in the scene and repositioned)
Adding objects from another blend also have this stutter as I just could test it out with this code:
Adding an object or an entire collection from another blend placed in the same path
import bge
import bpy
scene = bge.logic.getCurrentScene()
blendfile = "untitled.blend" # edit this (name of the blend file placed in the same directoy)
abs_filepath = bpy.path.abspath("//" + blendfile)
blendfile = abs_filepath
#############################################################
#### for an object uncomment this:
#section = "\\Object\\"
#filename = "Cubelo" # edit this (name of the object)
### for a collection uncomment this:
section = "\\Collection\\"
filename="Collection_lib" # edit this (name of the collection)
###############################################################
directory = blendfile + section
bpy.ops.wm.append(filename=filename, directory=directory)
#################################################################
### for an object uncomment this:
#scene.convertBlenderObject(bpy.data.objects[filename])
### for an entire collection uncomment this:
scene.convertBlenderCollection(bpy.data.collections[filename],True)
####################################################################
You would need to edit the script to your liking (blend file name, object name or collection name) and invoke the script in logic bricks e.g. by keyboard.
Trying it out Blender crashed 1x but this time it worked:
im not accustomed to either of these… my guess is that resterizer is for texture rendering slowly or not at all will depsgraph is objects not appearing at all? I searched them up but just got the basic meaning of them which is where I got my guesses from.
yeah it’s alright, I was thinking more about adding the whole map into the scene and hiding it with a loading screen. that way there are not multiple maps on the same file and in that way I can bring in objects from the other scenes without the stutter for performance. my thoughts are to have a main scene that has the most useful objects that will be used constantly like weapons, items, or particle effects while holding everything else in a different file like maps, enemies, and cutscenes. so basically everything that one can simply hide behind a loading screen which it’s what it is meant to do. im pretty sure this is the norm for bigger games right?
oh for sure for sure. this is a war that will never change or end. one can only be prepared for it and thanks to you I am now better off equipped than what I was before.
ok i know that i might be the devil for you right now with all my crazy ideas and foolish suggestions/requests and you can deny any of them at any time. so please do if you don’t want to do it. that being said here’s my crazy idea. is it possible to keep track of the player’s movement and when the player presses a key their character will be pulled back 5sec before? so what some racing games already do now but without the pausing just instant teleport back.
reason for my request is that it would be a cool ability for the ball to have for when they get pushed off the map the player can return back time on their ball and get the drop on the enemy player.
p.s. im starting to add reasons with my project as an example so it can be easier to understand. my guess is to save players location every sec and then load the 5th save but im not sure if this is the best way to do this or if it will be more harm then good to the performance.
This has virtually no impact on performance. I already had a replay system in my Helicopter demo
so this was not too complicated. This code here saves the Player’s position every second and on key press T he will be repositioned to the position 5 seconds ago.
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
keyboard = bge.logic.keyboard
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
player = scene.objects['Ball']
### how many seconds to jump back
seconds=5
if not 'init_time_jump' in own:
own['init_time_jump']=True
own['time_jump_timer']=0
own['time_jump_List']=[]
if len(own['time_jump_List'])==seconds:
own['time_jump_List'].pop(0)
if own['time_jump_timer']==0 and len(own['time_jump_List'])<seconds:
own['time_jump_List'].append(player.worldPosition.copy())
if own['time_jump_timer']==60:
own['time_jump_timer']=0
else:
own['time_jump_timer']+=1
### edit this for a different key
if JUST_ACTIVATED in keyboard.inputs[bge.events.TKEY].queue:
player.localLinearVelocity*=0
player.localAngularVelocity*=0
player.worldPosition=own['time_jump_List'][0]
own['time_jump_List'].clear()
own['time_jump_timer']=0
You can change the duration here:
### how many seconds to jump back
seconds=5
The code is conected to an always sensor. I left out a keyboard sensor (to keep logic bricks uncluttered), if you want to change the key then edit this line:
### edit this for a different key
if JUST_ACTIVATED in keyboard.inputs[bge.events.TKEY].queue:
Oh, the helicopter demo is fascinating, and ill definitely use it to better my understanding of python. also, the time jump is exactly what I hoped for thank you very much. ill later test myself and combine your helicopter one and the time jump to create an ability when the player time jumps he will also leave a moving afterimage of itself but that will be a much later fun project for myself. never the less this is awesome and thanks a lot.
Ok, this next one is completely a hail mary and I really don’t see this being possible at all. I don’t even know how one would even start with this. So if somehow you manage to make this ill make another donation. The idea is to somehow be able to make a Boolean will ingame towards the camera’s aim. So have a ray that when activated it will create a Boolean/hole on a mesh.
The reason is that the ball will have a weapon that creates holes on the map for the other balls to fall through and after a few secs later the holes gos back to normal. Boolean alone is annoying but I can’t imagine being able to quickly create Boolean holes within the in-game engine and not within the blenders modeling. Honestly, I don’t see this being possible but you have proven me wrong so here’s a gamble. also, this might be my last request I have troubled you for far too long and im confident that I can handle the rest from here. ill keep adding updates on my project here once in a while.
The boolean hole weapon sounds tricky (to create).
If a true boolean is impossible one could try to fake it by adding a plane that looks like a hole and let the enemy sink.
A little bit like the green acid slime here:
2 Questions:
will the holes only be possible on the lowest platform or should the enemy also fall down onto a lower platform
how do you imagine the player to set the place for the hole?
sorry that it took me so long to reply. i just got home from work 2 hours ago and immediately jump in the blend file to see if i can find out the problem.
ok i see what the problem is. so the engine is able to create Boolean but the Boolean it self doesn’t change the mesh’s colliders to allow the player to enter the Boolean. this is a tricky problem indeed.
I don’t think the mesh is the problem because the hole is there and the Boolean did work and it is real. what i think is happening here is that the box mesh’s collision is taking priority over the added Boolean. my reasoning is with this video of the ball still colliding with the box mesh but only colliding with the inside of the Boolean mesh. in order for this to happen i did delete the two faces of the Boolean to allow the ball to enter in the first place.
the only way to make the ball go through the boolean is to somehow remove the collision on the box mesh first. my guess is to have a collider on the boolean that once the ball hits either side of the boolean then the box’s collider is removed, only allowing the boolean collision. this could work but i can already foresee players somehow finding ways to abuse this. maybe one player enters the boolean allowing other player to go through the box because its collision is turn off. to this maybe its possible to have the collision turn off only for the player that hits the boolean collision locally and not globally.
i hope this is making some sense because im losing my self just typing it down. the good thing is that i can already see the solution but i dont yet have the coding knowhow to easy apply it with my current knowledge.
P.S of the boolean collision that turns off the box’s collision might need to be another invisable mesh that have the ghost physics type applied on each side of the boolean for the ball to be able to enter and exit boolean and remove and add the box’s collision respectively depanding from which side the ball is entering and exiting the boolean. also i think 5 sec on the boolean is not much time for the ball to pass through and its also really bad for testing purposes… maybe 10 or 15 secs…
The problem was that the collision mesh of the boolean didn’t update when I change the cutter object position in game. The physical hole still was there where it was when the game engine started and the function for this case to update the collision mesh reinstancePhysicsMesh(*gameObject*, *meshObject*, *dupli*, *evaluated* )
wasn’t working . WASN’T hahahahaha. One just has to wait 1 or a few frames for the engine to evaluate before updating with the function.
The same has to happen when the hole is removed .
Also:Now you don’t have to give the objects the modifier, the code will add and remove it.
Please try the above updated version.
The hole respawn is just deactivated.
I must say I never thought this was actually possible!
(If the collision mesh updating should fail, then we can also give the engine some more frames Hope it works on your pc.)
HAHAHHA so it was a simple fix and here i was going on a crazy elaborate system to make this work…
um i knew this was gonna happen… we might need to add the respawn on either side of the hole or else this happens…
yes this does work easily on my pc which i do hope it does because my pc is the closest you can get to the best gaming pc one can build. well that’s enough bragging on my part.
yeah me either but once you said that the engine had a boolean function thats when i knew that this had to work one way or another.
i hope making this was enjoyable and not painful at all either way i am hold up my end of the pledge and hope this is enough for pulling up with my crazy nonsense.
well, the update on the boolean physics is instant for me as for as I can see. ill keep in mind that this could be a possible problem in the future for players with slow PCs.
P.S also, im taking the trap code because it can still be used as a type of stun. honestly, there is a lot of material here for me to study python… all I need now is more time in the day… but ill get there one way or another. maybe not to your level but hopefully close enough.
thank you sooo much for your support in an unexpected order of magnitude I really can’t put into words!!!
Haha, although it looks so funny when trapped…I looked into this. Ironically what seems as a little problem isn’t so easy. To find out if the player is inside an object.
These didn’t work:
check collision with the cutting cylinder, because the cylinder is fixed size and can also extend to the outside.
check collision with the object itself.
check with a ray from the player to the camera if the hitpoint face normal is in same direction with the ray.
etc.
So I ended up with sending a ray in all 6 directions (in the moment when the hole closes) and if all hit a ground we can assume the player is inside. (this means this system must be altered if your scene has ground everywhere. Just to remember)
If the player is inside we respawn him to the point when he pressed left mouse button.
Keep it at a safe place because I have just tidied up the code in the files above and removed this bit (as the new code doesn’t need a collision sensor anymore)
The Boolean Hole System is now merged in the VWorld file but resides in its own Collection (and can be appended or linked).
The unused code for appending objects or collections from other blend files is also saved in the VWorld version. For all cases
It was quite a challenge but - I have to say this - a whole lot of fun!!! We found out quite really cool stuff, that really works (!!!) and opens up many more possibilties!
I took the freedom and changed the time jump so it plays back in reverse instead of just jumping. But you can set the parameters to minimum if you want to have an instant jump.
### edit this
seconds=5 ## min 1, how many seconds to jump back, min 1
records_per_second=10 # min 1, max 60, how fine the recording
backtime_intervall=1 # "reverse playback speed" shorter = faster min=1