pushed up with force

When i add cube floor that overlap it makes my character be pushed up with force.How would i prevent the character from being pushed up with force?


import bge
cont=bge.logic.getCurrentController()
own=cont.owner()
sens=cont.sensors['Collision']
if own['on']=on and sens.positive:
    Vex=own.getVectTo(sens.hitObject)
    sens.hitObject.applyForce(Vex*sens.hitObject.mass*20,0)

Attachments

PushIT.blend (433 KB)

This is dynamic loading of parented cubes that are the ground problem.Will It work with instanced objects?

I am sorry, But I have no idea what you are asking,

http://www.quickmeme.com/img/fd/fd8203b8ac30c066f72af14c3fab9c6256640c5046a6555ff5d90aa8e2d5fe45.jpg

ok, so in the generator you need,

distFromPlace=player.worldLocation-nextAdded.location
if distFromPlace<2:
    player.worldPosition.z+=(2.05-distFromPlace)
placeBlock

so if you are placing a block, and the player is inside the 2x2x2, move him up the distance from the center,

I am not that good of a coder.So where would i place it in this code?

'''
Created on 30 Aug 2014
@author: koala_boy166
'''
#import needed libraries
import bge, os, pickle, random
from bge import logic
#set constant variables
cont = logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()
objList = scene.objects
#list to store area locations is checked, if it doesn't exist a new one is created later on
def loadWorld():
    #Reset player position
    own.worldPosition = (0.0, 0.0, 5.0)
    
    if os.path.exists("save.p"):
        PlacedList = pickle.load(open( "save.p", "rb" ))
        
        #upon loading the list place terrain at each point in the list (stored as x,y,z)
        for item in PlacedList:
            Area = scene.addObject('Base_Area',own)
            Area.worldPosition = (item[0],item[1],0.0)
        
    if not os.path.exists("save.p"):
        PlacedList = []
        saveWorld(PlacedList)
        
    return PlacedList        
    
#Saves the world using pickle        
def saveWorld(data):
    pickle.dump(data, open( "save.p", "wb" ))
    print("World Saved")
    
#Deletes the world
def delWorld():
    os.remove("save.p")
    print("World Deleted")
    
# Place Area at position
def placeArea(x,y,PlacedList):
    
    # Add Area at position x,y
    Area = scene.addObject('Base_Area',own)
    Area.worldPosition = (x, y, 0)
    
    # Set Area rotation to 0 so they line up nicely
    rotation = Area.worldOrientation.to_euler()
    if (rotation.z > 0):
        rotAmount = (rotation.z * -1)
    if (rotation.z < 0):
        rotAmount = (rotation.z * -1)
    if (rotation.z == 0):
        rotAmount = 0.0    
    Area.applyRotation( [0.0,0.0,rotAmount], True)
    
    # Append Area location to our list so we don't get doubles in our terrain
    PlacedList.append((x, y))
    #Generate structures i.e. grass
    genStructures(Area, Area)
    
    
#round off position to nearest base
def roundnum(x, base):
    return int(base * round(float(x)/base))
#return rounded value of player position
def getRounded(x,y,base):
    RoundedXY = (roundnum(x,base), roundnum(y,base))
    return RoundedXY
# Run script
def main(areaList):
    
    
    # Base needs to be double to size of the Area (in this case 20) for proper placement
    base = own['Base']
    #Distance from edge player needs to be to trigger new Area spawn
    DistanceTrigger = own['DistanceTrigger']
    
    # Get player position
    pos = own.position
    x = pos[0]
    y = pos[1]
    
    # Get rounded number
    rounded = getRounded(x,y,base)
    own['Position_X'] = rounded[0]
    own['Position_Y'] = rounded[1]
    
    # Check distance on X+ axis
    if (x >= (own['Position_X']+(base/2)-DistanceTrigger)) and (x > own['Position_X']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X']+base, own['Position_Y']) in areaList:
            placeArea(own['Position_X']+base, own['Position_Y'],areaList)
            
            
            
    # Check distance on X- axis
    if (x <= (own['Position_X']-(base/2)+DistanceTrigger)) and (x < own['Position_X']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X']-base, own['Position_Y']) in areaList:
            placeArea(own['Position_X']-base, own['Position_Y'],areaList)
        
        
        
    # Check distance on Y+ axis
    if (y >= (own['Position_Y']+(base/2)-DistanceTrigger)) and (y > own['Position_Y']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X'], own['Position_Y']+base) in areaList:
            placeArea(own['Position_X'], own['Position_Y']+base,areaList)
            
            
            
    # Check distance on Y- axis
    if (y <= (own['Position_Y']-(base/2)+DistanceTrigger)) and (y < own['Position_Y']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X'], own['Position_Y']-base) in areaList:
            placeArea(own['Position_X'], own['Position_Y']-base,areaList) 
    
# main program loop
def genStructures(MESH,object):
    
    #for each property on the terrain
    AllProperties = object.getPropertyNames()
    for i in range(0, len(AllProperties)):
        currentGen = AllProperties[i]
        
        spawnChance = object[currentGen]
        offset = 1.0
    
        mesh = MESH.meshes[0] # There can be more than one mesh...
        for v in range(mesh.getVertexArrayLength(0)):
            vert = mesh.getVertex(0, v)
            vert.color = [1,0,1,1]
            testX = (vert.x * own['Size']) + MESH.worldPosition[0] 
            testY = (vert.y * own['Size']) + MESH.worldPosition[1]
                
            Chance = random.randrange(1,100)
            print(Chance)
            if Chance <= spawnChance:
                grass = scene.addObject(currentGen,own)
                grass.worldPosition = (testX,testY,offset)
    
    
AreaList = loadWorld()
placeArea(0.0,0.0,loadWorld())           
       
def run():
    main(AreaList)
def save():
    print(AreaList)
    saveWorld(AreaList)

this is a hack in, I would need a blend to test,
how big are each area?

'''Created on 30 Aug 2014
@author: koala_boy166
'''
#import needed libraries
import bge, os, pickle, random
from bge import logic

#set constant variables
cont = logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()
objList = scene.objects
if 'player' not in own:
    own['player']=scene.objects['player']
else:
    player=own['player']
#list to store area locations is checked, if it doesn't exist a new one is created later on
def loadWorld():
    #Reset player position
    own.worldPosition = (0.0, 0.0, 5.0)
    
    if os.path.exists("save.p"):
        PlacedList = pickle.load(open( "save.p", "rb" ))
        
        #upon loading the list place terrain at each point in the list (stored as x,y,z)
        for item in PlacedList:
             
            Area = scene.addObject('Base_Area',own)
            Area.worldPosition = (item[0],item[1],0.0)
            playerDist=player.GetDistanceTo(Area)
            if playerDist<2:
               player.worldPosition.z+=playerDist


        
    if not os.path.exists("save.p"):
        PlacedList = []
        saveWorld(PlacedList)
        
    return PlacedList        
    
#Saves the world using pickle        
def saveWorld(data):
    pickle.dump(data, open( "save.p", "wb" ))
    print("World Saved")
    
#Deletes the world
def delWorld():
    os.remove("save.p")
    print("World Deleted")
    
# Place Area at position
def placeArea(x,y,PlacedList):
    
    # Add Area at position x,y
    Area = scene.addObject('Base_Area',own)
    Area.worldPosition = (x, y, 0)
    
    # Set Area rotation to 0 so they line up nicely
    rotation = Area.worldOrientation.to_euler()
    if (rotation.z > 0):
        rotAmount = (rotation.z * -1)
    if (rotation.z < 0):
        rotAmount = (rotation.z * -1)
    if (rotation.z == 0):
        rotAmount = 0.0    
    Area.applyRotation( [0.0,0.0,rotAmount], True)
    
    # Append Area location to our list so we don't get doubles in our terrain
    PlacedList.append((x, y))
    #Generate structures i.e. grass
    genStructures(Area, Area)
    
    
#round off position to nearest base
def roundnum(x, base):
    return int(base * round(float(x)/base))
#return rounded value of player position
def getRounded(x,y,base):
    RoundedXY = (roundnum(x,base), roundnum(y,base))
    return RoundedXY
# Run script
def main(areaList):
    
    
    # Base needs to be double to size of the Area (in this case 20) for proper placement
    base = own['Base']
    #Distance from edge player needs to be to trigger new Area spawn
    DistanceTrigger = own['DistanceTrigger']
    
    # Get player position
    pos = own.position
    x = pos[0]
    y = pos[1]
    
    # Get rounded number
    rounded = getRounded(x,y,base)
    own['Position_X'] = rounded[0]
    own['Position_Y'] = rounded[1]
    
    # Check distance on X+ axis
    if (x >= (own['Position_X']+(base/2)-DistanceTrigger)) and (x > own['Position_X']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X']+base, own['Position_Y']) in areaList:
            placeArea(own['Position_X']+base, own['Position_Y'],areaList)
            
            
            
    # Check distance on X- axis
    if (x <= (own['Position_X']-(base/2)+DistanceTrigger)) and (x < own['Position_X']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X']-base, own['Position_Y']) in areaList:
            placeArea(own['Position_X']-base, own['Position_Y'],areaList)
        
        
        
    # Check distance on Y+ axis
    if (y >= (own['Position_Y']+(base/2)-DistanceTrigger)) and (y > own['Position_Y']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X'], own['Position_Y']+base) in areaList:
            placeArea(own['Position_X'], own['Position_Y']+base,areaList)
            
            
            
    # Check distance on Y- axis
    if (y <= (own['Position_Y']-(base/2)+DistanceTrigger)) and (y < own['Position_Y']):
        
        # Check if area has been placed, if not then add in the area
        if not (own['Position_X'], own['Position_Y']-base) in areaList:
            placeArea(own['Position_X'], own['Position_Y']-base,areaList) 
    
# main program loop
def genStructures(MESH,object):
    
    #for each property on the terrain
    AllProperties = object.getPropertyNames()
    for i in range(0, len(AllProperties)):
        currentGen = AllProperties[i]
        
        spawnChance = object[currentGen]
        offset = 1.0
    
        mesh = MESH.meshes[0] # There can be more than one mesh...
        for v in range(mesh.getVertexArrayLength(0)):
            vert = mesh.getVertex(0, v)
            vert.color = [1,0,1,1]
            testX = (vert.x * own['Size']) + MESH.worldPosition[0] 
            testY = (vert.y * own['Size']) + MESH.worldPosition[1]
                
            Chance = random.randrange(1,100)
            print(Chance)
            if Chance <= spawnChance:
                grass = scene.addObject(currentGen,own)
                grass.worldPosition = (testX,testY,offset)
    
    
AreaList = loadWorld()
placeArea(0.0,0.0,loadWorld())           
       
def run():
    main(AreaList)
def save():
    print(AreaList)     saveWorld(AreaList)

The size property is 300.Did you read how to use it?Here is the read me.

‘This is version 0.2a of my terrain generator with the implementation of save/load
code has been cleaned in anticipation of future features
save file is stored as save.p in the same directory as the blend file
Everything works the same as the previous release with the exception of the save
feature. To use it press o whilst in game, upon restarting the game youll have your
saved world, to delete the world press t
and here is the instructions’
“”" INSTRUCTIONS INSTRUCTIONS “”"
“”" INSTRUCTIONS INSTRUCTIONS “”"
“”" INSTRUCTIONS INSTRUCTIONS “”"

Name your terrain Base_Area and place it in a different layer

Attach this script to your player

Must be attached as always (true triggered)

Python module controller (Add_Area.main)

your player needs five properties

‘Position_X’ (integer) is used to store X grid placement (set it as 0)

‘Position_Y’ (integer) is used to store Y grid placement (set it as 0)

‘Base’ (integer) property is needed for grid size (should be double your terrain scale (press n to see it))

i.e. your terrain x,y scale is 10 so Base needs to be 20

‘DistanceTrigger’ (integer) is how far away from the edge of the terrain you need to be

in order to add the next area (can’t be negative, ideally it should be half your terrain size)

‘Size’ which is the size of your terrain piece

in order to get random generation working with your models

add a int property on the terrain mesh with the same name as your object

the value is the spawn chance (lower = rarer) move your object into a different scene from

your player and terrain mesh and done!

(MAKE SURE YOU USE A LOD SYSTEM IF YOU USE THIS FOR REAL MODELS!!! BLENDER HAS IT INBUILT

SO THERE IS NO EXCUSE, WANT HIGHER FRAMERATES? USE LOD)

“”" END INSTRUCTIONS END INSTRUCTIONS “”"
“”" END INSTRUCTIONS END INSTRUCTIONS “”"
“”" END INSTRUCTIONS END INSTRUCTI

I tried what you said and you know what it still does the same thing.

Here is blend of dynamic loading blueprintrandom.

Attachments

dynamic loading .blend (646 KB)