Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; In the scene dsl:
- ;; Put the stickpoint wherever you want the thing to be in the world.
- (@stickpoint
- ((transform :translation/current (vec3 <x> <y> <z>)))
- ;; THis is the thing we're going to move around.
- (@ball ((transform)
- (ball-mover :scale 1))))
- ;; Then we need a componnet on the @ball
- (define-component ball-mover
- ((scale :default 1)
- (transform :default nil)))
- (defmethod initialize-component ((component ball-mover) (context context))
- (with-accessors ((actor actor) (transform transform)) component
- (setf transform (actor-component-by-type actor 'transform))))
- (defmethod update-component ((component ball-mover) (context context))
- (let* ((x (get-gamepad-axis context :gamepad1 :left-horizontal))
- (y (get-gamepad-axis context :gamepad1 :left-vertical))
- (movement-vec
- (v3:scale (v3:make (* x (sqrt (- 1 (* y y .5))))
- (* y (sqrt (- 1 (* x x .5))))
- 0)
- (scale ball-mover))))
- ;; Then, just overwrite the ball's position in relation to the @stickpoint
- ;; parent. And it'll move like how you desire.
- (v3:copy! (translate (transform component)) movement-vec)))
Add Comment
Please, Sign In to add comment