How to spawn a particular terrain only ounce in a endless runner videogame?Forgive me if it sounds vague.
AddObject Actuator / KX_Scene.addObject(âŚ)?
I mean how would i modify this endless runner demo to only place a terrain plane randomly only once?
Nobody understood my question?
Not sure but I think this is what youâre looking for:
infinite_runner2 (1).blend (409 KB)
I was trying to check that the absolute value of the x and y positions of the player were less than 1000 for the terrain to update. Hope it helps. And Iâm sure people wanted to help but sometimes we donât have time for such things haha :no:
Is the ground plane that spawns once the ground i am starting on?This is what i am asking for.I would like to know how i would spawn ground planes once in a endless runner videogame.Meaning you would only see them once in the entire game.You could not go back to them.
is the method you want for an 2d ârunnerâ or for 3d? If the ground will run under the player or the player run on the ground? There are so many ways to do it you should specify your Question a little bit more!
It will be a 3d videogame.The player will run on the ground.All you had to do is check the blend posted on post 5.
Your Terrain
Try creating a list of terrain game objects which you âaddObject()â or âinstantAddObject()â every time you pass a boundary. If you want smooth transitions between your terrain, I recommend applying some mist or filter that limits the playerâs vision, and gathering seamless textures.
Terrain Aesthetics Variance Without View Consideration
Try storing the current plane/terrain the player is on every time he/she lands on one. To check that the player has changed terrains, use a ray sensor which points downward and stores the terrain object. When this object has changed (get the object with hitObject), change the previous terrainâs look, or alternatively, replace the entire previous terrain with another terrain. When the player has changed terrains, retrieve the terrain the player is currently standing on, and update the terrain on all sides of that terrain.
Ex) You are on a terrain E which takes up one BU. You cross over to the terrain B one BU ahead. In that case, add/update varying terrain one BU on all sides of terrain B.
Terrain Aesthetics Variance With View Consideration
If you donât want the player to be able to see these updates, I recommend parenting an invisible ghost boundary to each of the planes which extends beyond the surface of the planes themselves which, when touched, updates the plane specific to a given boundary. The idea is to have the player not notice the previous planes he/she stepped on have been updated.
In this case, you should also check that the player has landed on that specific plane first before checking for boundary collisions for that specific plane.
Also, try creating an âinvalidSpawnListâ (or possibly even just globalDict) which stores in locations which have been spawned on already. Whenever the player lands on a terrain, spawn terrain on all sides of that terrain according to the list, and update the list.
If you only add each piece of terrain once, it wonât be infinite.
Not each terrain just some terrains.Some terrains are added once while the others are added over and over again while you move near there edges.Like a endless runner videogame.
How would i prevent a certain type of terrain that has already spawned from respawning again?
this is easy ⌠remember what types where used already.
E.g.
- have a set of spawnable types.
- randomly spawn one of the available types - spawn it and remove it from the set
-> be aware the list ill be empty after each type was taken away.
Modify the solution from above, but remove only âuniqueâ types from the set of spawnble types.
Alternatives:
- Different probability to be picked
- different number of picks before the type can be picked again (e.g. by re-adding to the set)
It is not easy for me.I have never done it before.Could i have blendfile example?
It is not easy for me
No it is not. Itâs not easy for anyone the first time they do something
Could i have blendfile example?
We do not exist simply to create sample blend files for other people.
So try creating something nice and simple with python. Try using it for trivial tasks you would normally use logic bricks for. Try getting a python controller to add an object, any object, anywhere. Then try figure out how to get it to place that object at a specific location.
How would i prevent a certain type of terrain that has already spawned from respawning again?
That depends on how you want to spawn your terrain. Monsterâs idea works for a set of tiles you already have, for example.
It is not easy for me.
Actually, what Monster is referring to is the concept, which is easy to grasp. The implementation is a different story however.
And yes, please provide us with a blend file showing us that you tried to implement the concepts we have shown.
Here, I have even tried to get you (minimally) started with a 3x3 terrain. But this is only a starting point. I have included a few planes, and a way to spawn them in a grid like fashion. It does not implement any main features we have stated.
terrain.blend (517 KB)
Thanks for understanding. Please do continue to ask if you need more help.
How do i know if i am really learning something.Unless i am tested.
Why this does not work?
if owner['var'] in range(0, 5):
actuators["spawner2"].object = scene.objectsInactive["Plane"]
actuators["spawner2"].EndObject()
It seems you should change EndObject() to endObject(). You can find out what errors you have under (Window - Toggle System Console). Also, endObject() is only used for deleting game objects, which are objects in your scene(s) (active or inactive). You canât end an actuator with endObject().
Well I sense you are not familiar with blender code/docs. I recommend you try to implement something simpler, such as adding an object to a scene. I think you should go to youtube/search engine and search for video or text tutorials outlining the basics of coding in blender only if you are not comfortable at all coding.
Or otherwise, you can take a look at the blender docs: https://www.blender.org/api/blender_python_api_2_78a_release/
Under âGame Engine Modulesâ, have a look at Game Logic (bge.logic), and try to study the various sensors (and other things).
Basically, you start with âcontroller = bge.logic.getCurrentController()â, then âcontroller.ownerâ
Then, you can access actuators with:
actuators = controller.actuators
Then, you can reference a specific actuator with actuators[âmySpecificActuatorâ], where âmySpecificActuatorâ is the name of your actuator.
Make sure you use the âbgeâ module and not the âbpyâ.
It is not like it is the first time i coded in bge python before.It is just that i had not did it in a while.
Ah, I see. Iâm sorry if I came off as trying to judge you because I thought you didnât have basics down, but I was not trying to judge you, nor would I judge anyone for not having basics down. If you donât have basics down, I believe this is the place to ask for questions, because this is what the site was designed for in the first place.
Please donât feel discouraged from asking simple questions. I wonât judge you for that. Please know that I wasnât trying to belittle you by giving you beginnerâs code information.