ํ์ด์ฌ ์ฒ์ ๋ฐฐ์ฐ๋๋ฐ..ย ย pyBox2D๋ฅผ ๊น์๋ดค์ด์
์ธํฐ๋ท์์ ์์ ์ฝ๋ ๋ฐ์ ํด๋ณด๋๋ฐ
from Box2D import *
world = b2World(gravity = (0, -10), doSleep = True)
ground1BodyDef = b2BodyDef()
ground1BodyDef.position.Set(0, 0)
ground1Body = world.CreateBody(ground1BodyDef)
ground1Shape = b2PolygonShape()
ground1Shape.SetAsBox(50, 1)
ground1Body.CreateFixture(shape = ground1Shape)
box1BodyDef = b2BodyDef()
box1BodyDef.type = b2_dynamicBody
box1BodyDef.position.Set(0, 5)
box1Body = world.CreateBody(box1BodyDef)
box1Shape = b2PolygonShape()
box1Shape.SetAsBox(1, 1)
box1FixtureDef = b2FixtureDef()
box1FixtureDef.shape = box1Shape
box1FixtureDef.density = 1
box1FixtureDef.friction = 0.3
box1Body.CreateFixture(box1FixtureDef)
timeStep = 1.0 / 60
velocity = 6.0
positers = 2.0
for i in range(60):
ย ย world.Step(timeStep. velocity, positers)
ย ย world.ClearForces()
ย ย print(box1Body.position)
'float' object has no attribute 'velocity'
File "D:\(ํด๋๋ช
์ ๊ฐ๋ฆด๊ฒ์)\test_123.py", line 29, in <module>
world.Step(timeStep. velocity, positers)
์ ์ค์์ ๋ฌธ์ ๊ฐ ๋จ๋๋ฐ
์ข ์ฐพ์๋ดค๋๋ฐ ์ด ์ค๋ฅ ๋ฐ๋๋ ์คํ๋ ๋ชจ๋์ด๋ฆ์ด๋ ํ์ผ ์ด๋ฆ์ด๋ ๋๊ฐ์ด ํด์ ๊ฑธ๋ฆฌ๋
๊ทธ๋ฐ ๊ฒฝ์ฐ๋ฐ์ ์๋๋ผ๊ตฌ์
Step() ์ธ์๋ค ๋ณด๋๊น Any, Any, Any ๋๋ฐ ์ timeStep์ ์ค๋ฅ๊ฐ ์๋๊ณ velocity๋ง ์ ๋ฐ๊ฑด๊ฐ์
๋์์ฃผ์ธ์... ๋ถํ๋๋ ค์ฉ
timeStep. -> timeStep,
Exception has occurred: TypeError in method 'b2World_Step', argument 3 of type 'int32' File "D:\2DGP_Project\test_123.py", line 29, in world.Step(timeStep, velocity, positers)
๊ฐ์ฌํฉ๋๋ค..ใ ใ ์ด๋ฐ ์คํ ์ค์๋ฅผ... ์ค๋ฅ๊ฐ ํ๋ ๋ ๋ด๋๋ฐ ์ด๊ฑด ์ ๊ฐ ์ฐพ์๋ณผ๊ฒ์ฉ
https://box2d.org/documentation/classb2_world.html#a82c081319af9a47e282dde807e4cd7b8
2, 3๋ฒ์งธ ์ธ์๋ int๋ก ๋๊ฐ์ผํจ
์ค.. ํ๋ฆฌ...
ํน์ ์ฐ๊ธฐ๋์? 2dgpใ ใ ใ - dc App