is this syntax correct, is this syntax only setting a variable

Started by William, November 12, 2023, 19:37:38

Previous topic - Next topic

William

ElseIf EntityDistance(me.pivot, terrain) < EntityY(me.pivot) = 0can you tell me if entityY(me.pivot) is a variable being set to 0 or if it translates to entitydistance being lesser than Y than = 0.

im trying to prevent player from being moved below terrain, playerisonground sometimes becomes false and the player is moved negative -Yaxis, downward to below terrain. where prior to that player playerisonground equaled true. i have no idea why but something triggers playerisonground  to equal false. if the if statement in above code equals true it means player is on ground = false
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

i believe its an openb3d error, sometimes there is collision between the entity player and the corner of the terrain where entity players spawn and not other client application execution. there are clause for that of the bmx code to happen i believe the player is pushed below terrain due to collision with something positioning entity negative Y.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

angros47

It's not possible to give you a complete answer, seeing only one line of code, but that syntax looks wrong, to me: first of all, you basically test

if a<b=0
that doesn't make much sense.

Also, from your code, I have the impression you are trying to use EntityDistance to measure the distance from the ground. That's not how EntityDistance works. It measures the distance between two points, not between a point and a surface, and one of the points is the position of me.pivot, the other is the position of the terrain (usually 0,0,0, if you never used MoveEntity on it).

William

ahh, okay. yes. i already forgot. well, i mean just because its a surface with noise.. i see what your saying though. it is judged by position not nearest position and shape. so i may have to find a way to linepick a distance measurement to the nearest point relative to the entity player.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

angros47

Look at the guide for the commands LinePick, EntityPick and EntityPickMode.

Midimaster

The player can get below the terrain, when the EntityRadius() is too small and you do not check Collision in the crucial moment. Afterwards there is no collision anymore and the entity falls and falls....

So the first question I have is: Does the Player fall deeper and deeper if this happens? Or does the player move straight on with feed below the ground?

If the player keeps on moving straight (but too low), the following sentences are unsuitable, because the problem needs a different solution.

The player falls through the ground:


You are right: You can also check the EntityDistance() between Terrain and Player, but this is always >0, because distances are always positive. So this does not solve your task.

We have EntityY() for the player and TerrainY() for the Terrain. And if we compare both, you can find out if the player is below the ground:

local pX:Int = EntityX(Player)
local pZ:Int = EntityZ(Player)
If EntityY(Player) < TerrainY(Terra, pX, pZ)
    print "Player below ground"
Endif

You may need to add a little value to get optical correct impressions:

local pX:Int = EntityX(Player)
local pZ:Int = EntityZ(Player)
If EntityY(Player) < ( TerrainY(Terra, pX, pZ) + 0.03 )
    print "Player below ground"
Endif
...crossing the alps with my bike at the moment

angros47


William

i tried it, and the player still falls below terrain. im going to try setting an entity radius of each to 1? i mean i dont know the size of the terrain right now how its interpreted, radius 1 or the actual size of the terrain. your probably right it is the radius.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

fudge, setting the radius to 1 hadnt seemed to solve the issue.


here is the code.
' Gravity and jumping function
If  PlayerTime<MilliSecs() And PlayerIsOnGround=False'And YAcceleration<>0
PlayerTime = MilliSecs()+ MOTION

YAcceleration = YAcceleration - GRAVITY

MoveEntity me.Pivot, 0,YAcceleration,0
'Print EntityY(Pivot)
If EntityY(me.Pivot)<0
'  auto floor collision or:
'PositionEntity me.Pivot, EntityX(me.Pivot), 1 , EntityZ(me.Pivot)
YAcceleration=0
EndIf
EndIf

Local WhoCollided:TEntity = EntityCollided(me.pivot,GroupEnvironment)
If WhoCollided=terrain
     'Print "Entity has collided with the terrain"
PlayerIsOnGround = True
ElseIf EntityY(me.pivot) > ( TerrainY(terrain, pX, pY, pZ) + 0.03 )
PlayerIsOnGround = False
'Print "player isnt colliding with anything"
EndIf

i'll try just using your code snippet for doing a manual collision as you intended. i believe its is the result of an incline of the terrain i think the terrain isnt entirely flat. sometimes the player spawns in other locations and sometimes the player spawns where the player is supposed to be. can you tell me if it is an error in openb3d/blitzmax?
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

Midimaster

I see in your code, that you move the pivot instead of the player's entity when jumping. Shouldn't the pivot always stay on the ground? And only the body should "fly"?
...crossing the alps with my bike at the moment

William

i dont know, i want the entity player to be able to jump over obstacles.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

pivot coordinates
14.0000000
1.00099063
-15.0000000
playerentity coordinates
0.00000000
0.00000000
-0.00000000

trying to test the hypothesis that perhaps it only appears the player falls through the terrain. what i can tell you is that sometimes the pivot is positioned at those coordinates and sometimes when the client starts the player/pivot is positioned at 0,0,0.

well, how can i print global coordinates of playerentity to pivot to match alignment? i have had a feeling that perhaps the model is not positioned at 0,0,0 in the model editor that perhaps its misaligned with pivot or something.

but those coordinates, i am going to look at the function document to see if there is a flag argument to print the actual (I think they're called global and local) coordinates to align them properly if there is a misalignment.

edit: 'll have to check with a model editor the position/coordinates.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

angros47

The coordinates of playerentity are set to zero because they are related to its parent entity (pivot, I suppose)

To get the global coordinates you have to use the global flag in EntityX, EntityY, EntityZ. So, EntityX(playerentity, 1)