kandi background
kandi background
Explore Kits
kandi background
Explore Kits
Explore all Minecraft open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Minecraft

Byte Buddy 1.12.8

1.3.4

2022.6.0

v1.8.1

v3.5.2.218

byte-buddy

Byte Buddy 1.12.8

mumble

1.3.4

docker-minecraft-server

2022.6.0

baritone

v1.8.1

HMCL

v3.5.2.218

Popular Libraries in Minecraft

Trending New libraries in Minecraft

Top Authors in Minecraft

1

40 Libraries

5314

2

33 Libraries

224

3

25 Libraries

453

4

25 Libraries

135

5

23 Libraries

158

6

23 Libraries

167

7

22 Libraries

315

8

22 Libraries

1081

9

22 Libraries

733

10

21 Libraries

338

1

40 Libraries

5314

2

33 Libraries

224

3

25 Libraries

453

4

25 Libraries

135

5

23 Libraries

158

6

23 Libraries

167

7

22 Libraries

315

8

22 Libraries

1081

9

22 Libraries

733

10

21 Libraries

338

Trending Kits in Minecraft

No Trending Kits are available at this moment for Minecraft

Trending Discussions on Minecraft

    First-person controller y-pos logic in Ursina
    How to configure slf4j (for JDA) to work with log4j (for Minecraft Paper)?
    Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
    Log4j vulnerability - Is Log4j 1.2.17 vulnerable (was unable to find any JNDI code in source)?
    Minecraft Plugin ClassNotFound Error from External JAR
    Infer dependencies in Gradle subproject from its parent project
    Minecraft Forge 1.7.10 Custom Entity Not Spawning On The Client?
    Generate custom ores in custom dimension
    Special condition - remove all the version numbers from the mods to search for the new version
    How to filter an array on click in react?

QUESTION

First-person controller y-pos logic in Ursina

Asked 2022-Mar-15 at 07:04

I have a clone of Minecraft and I want to see if the player falls off the island it would quit the game. I thought that if I wrote.

1if player.position == Vec3(x, -80, z):
2     quit()
3

it would quit the game but that didn't work so I don't know what to do.

Heres the Minecraft clone code.

1if player.position == Vec3(x, -80, z):
2     quit()
3from ursina import *
4from ursina.prefabs.first_person_controller import FirstPersonController
5app = Ursina()
6
7grass_color = color.rgb(1, 235, 113)
8stone_color = color.rgb(138,141,143)
9dirt_color = color.rgb(200, 157, 124)
10
11block_pick = 1
12
13def update():
14    if held_keys['escape']:
15        quit()
16
17    global block_pick
18
19    if held_keys['1']: block_pick = 1
20    if held_keys['2']: block_pick = 2
21    if held_keys['3']: block_pick = 3
22
23class Voxel(Button):
24    def __init__(self, position = (0,0,0), color = color.white):
25        super().__init__(
26            parent = scene,
27            position = position,
28            model = 'cube',
29            origin_y = 0.5,
30            texture = 'white_cube',
31            color = color,
32            highlight_color = color,
33                    )
34
35    def input(self,key):
36        if self.hovered:
37            if key == 'right mouse down':
38                if block_pick == 1:voxel = Voxel(position = self.position + mouse.normal, color = grass_color)
39                if block_pick == 2:voxel = Voxel(position = self.position + mouse.normal, color = stone_color)
40                if block_pick == 3:voxel = Voxel(position = self.position + mouse.normal, color = dirt_color)
41            if key == 'left mouse down':
42                destroy(self)
43            
44for z in range(20):
45    for x in range(20):
46        voxel = Voxel(position=(x,0,z), color = grass_color)
47
48for y in range(3):
49    for x in range(20):
50        for z in range(20):
51            voxel = Voxel(position=(x,y + -3,z), color = dirt_color)
52
53player = FirstPersonController()
54app.run()
55

ANSWER

Answered 2022-Mar-15 at 07:04

You checked only for a single value of the player's y position which won't work - after all, you'd be falling down quickly. You could check whether the player's height is below a certain cutoff:

copy icondownload icon

1if player.position == Vec3(x, -80, z):
2     quit()
3from ursina import *
4from ursina.prefabs.first_person_controller import FirstPersonController
5app = Ursina()
6
7grass_color = color.rgb(1, 235, 113)
8stone_color = color.rgb(138,141,143)
9dirt_color = color.rgb(200, 157, 124)
10
11block_pick = 1
12
13def update():
14    if held_keys['escape']:
15        quit()
16
17    global block_pick
18
19    if held_keys['1']: block_pick = 1
20    if held_keys['2']: block_pick = 2
21    if held_keys['3']: block_pick = 3
22
23class Voxel(Button):
24    def __init__(self, position = (0,0,0), color = color.white):
25        super().__init__(
26            parent = scene,
27            position = position,
28            model = 'cube',
29            origin_y = 0.5,
30            texture = 'white_cube',
31            color = color,
32            highlight_color = color,
33                    )
34
35    def input(self,key):
36        if self.hovered:
37            if key == 'right mouse down':
38                if block_pick == 1:voxel = Voxel(position = self.position + mouse.normal, color = grass_color)
39                if block_pick == 2:voxel = Voxel(position = self.position + mouse.normal, color = stone_color)
40                if block_pick == 3:voxel = Voxel(position = self.position + mouse.normal, color = dirt_color)
41            if key == 'left mouse down':
42                destroy(self)
43            
44for z in range(20):
45    for x in range(20):
46        voxel = Voxel(position=(x,0,z), color = grass_color)
47
48for y in range(3):
49    for x in range(20):
50        for z in range(20):
51            voxel = Voxel(position=(x,y + -3,z), color = dirt_color)
52
53player = FirstPersonController()
54app.run()
55def update():
56    if player.y < -80:
57        print('You fell to death!')
58        app.quit()
59

Source https://stackoverflow.com/questions/71475015

Community Discussions contain sources that include Stack Exchange Network

    First-person controller y-pos logic in Ursina
    How to configure slf4j (for JDA) to work with log4j (for Minecraft Paper)?
    Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
    Log4j vulnerability - Is Log4j 1.2.17 vulnerable (was unable to find any JNDI code in source)?
    Minecraft Plugin ClassNotFound Error from External JAR
    Infer dependencies in Gradle subproject from its parent project
    Minecraft Forge 1.7.10 Custom Entity Not Spawning On The Client?
    Generate custom ores in custom dimension
    Special condition - remove all the version numbers from the mods to search for the new version
    How to filter an array on click in react?

QUESTION

First-person controller y-pos logic in Ursina

Asked 2022-Mar-15 at 07:04

I have a clone of Minecraft and I want to see if the player falls off the island it would quit the game. I thought that if I wrote.

1if player.position == Vec3(x, -80, z):
2     quit()
3

it would quit the game but that didn't work so I don't know what to do.

Heres the Minecraft clone code.

1if player.position == Vec3(x, -80, z):
2     quit()
3from ursina import *
4from ursina.prefabs.first_person_controller import FirstPersonController
5app = Ursina()
6
7grass_color = color.rgb(1, 235, 113)
8stone_color = color.rgb(138,141,143)
9dirt_color = color.rgb(200, 157, 124)
10
11block_pick = 1
12
13def update():
14    if held_keys['escape']:
15        quit()
16
17    global block_pick
18
19    if held_keys['1']: block_pick = 1
20    if held_keys['2']: block_pick = 2
21    if held_keys['3']: block_pick = 3
22
23class Voxel(Button):
24    def __init__(self, position = (0,0,0), color = color.white):
25        super().__init__(
26            parent = scene,
27            position = position,
28            model = 'cube',
29            origin_y = 0.5,
30            texture = 'white_cube',
31            color = color,
32            highlight_color = color,
33                    )
34
35    def input(self,key):
36        if self.hovered:
37            if key == 'right mouse down':
38                if block_pick == 1:voxel = Voxel(position = self.position + mouse.normal, color = grass_color)
39                if block_pick == 2:voxel = Voxel(position = self.position + mouse.normal, color = stone_color)
40                if block_pick == 3:voxel = Voxel(position = self.position + mouse.normal, color = dirt_color)
41            if key == 'left mouse down':
42                destroy(self)
43            
44for z in range(20):
45    for x in range(20):
46        voxel = Voxel(position=(x,0,z), color = grass_color)
47
48for y in range(3):
49    for x in range(20):
50        for z in range(20):
51            voxel = Voxel(position=(x,y + -3,z), color = dirt_color)
52
53player = FirstPersonController()
54app.run()
55

ANSWER

Answered 2022-Mar-15 at 07:04

You checked only for a single value of the player's y position which won't work - after all, you'd be falling down quickly. You could check whether the player's height is below a certain cutoff:

copy icondownload icon

1if player.position == Vec3(x, -80, z):
2     quit()
3from ursina import *
4from ursina.prefabs.first_person_controller import FirstPersonController
5app = Ursina()
6
7grass_color = color.rgb(1, 235, 113)
8stone_color = color.rgb(138,141,143)
9dirt_color = color.rgb(200, 157, 124)
10
11block_pick = 1
12
13def update():
14    if held_keys['escape']:
15        quit()
16
17    global block_pick
18
19    if held_keys['1']: block_pick = 1
20    if held_keys['2']: block_pick = 2
21    if held_keys['3']: block_pick = 3
22
23class Voxel(Button):
24    def __init__(self, position = (0,0,0), color = color.white):
25        super().__init__(
26            parent = scene,
27            position = position,
28            model = 'cube',
29            origin_y = 0.5,
30            texture = 'white_cube',
31            color = color,
32            highlight_color = color,
33                    )
34
35    def input(self,key):
36        if self.hovered:
37            if key == 'right mouse down':
38                if block_pick == 1:voxel = Voxel(position = self.position + mouse.normal, color = grass_color)
39                if block_pick == 2:voxel = Voxel(position = self.position + mouse.normal, color = stone_color)
40                if block_pick == 3:voxel = Voxel(position = self.position + mouse.normal, color = dirt_color)
41            if key == 'left mouse down':
42                destroy(self)
43            
44for z in range(20):
45    for x in range(20):
46        voxel = Voxel(position=(x,0,z), color = grass_color)
47
48for y in range(3):
49    for x in range(20):
50        for z in range(20):
51            voxel = Voxel(position=(x,y + -3,z), color = dirt_color)
52
53player = FirstPersonController()
54app.run()
55def update():
56    if player.y < -80:
57        print('You fell to death!')
58        app.quit()
59

Source https://stackoverflow.com/questions/71475015