(Solved) I can't get Body:setAngularVelocity() working

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
JimOfLeisure
Prole
Posts: 9
Joined: Wed Dec 29, 2021 8:01 pm

(Solved) I can't get Body:setAngularVelocity() working

Post by JimOfLeisure »

Hi, I'm quite new to Love2d and am making a little prototype / game for a game jam for fun and glory.

The code in question: https://github.com/JimOfLeisure/bumpy-r ... nd.lua#L17

I have physics circle falling onto a physics rectangle called ground. I can setAngle(n) in the load() function successfully, but for grins I tried setAngularVelocity(n) , but it's not doing anything. I've tried setting it in load() , draw(), and update() , and I can use print statements to show myself that the code is actually running, but so far the "ground" doesn't rotate.

I'm sure I'm missing something simple, but I'm unable to figure it out so far. Can someone shed some light on this for me?

Thanks!

Editing to add: My expected behavior would be that the rectangle representing the ground would continually rotate around its center once I set the angular velocity to a nonzero number. setAngle(n) does what I expect in rotating the rectangle to that angle in radians, so I figured setAngularVelocity would create motion.

Edit: I figured it out! When creating the body with love.physics:newBody I needed to provide a type that can move, in this case "kinematic". It was the newBody call I messed up, not setAngularVelocity.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 17 guests