Discuss Scratch

Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

Hi! I need some help. I'm making a 3d top-down game and whenever I rotate on a certain position, my character can fall off. Is there a way I can change the center of rotation for an object to the camera position? Here is my script.

when I receive [ message1]
forever
go to x: (((size) / (100)) * (x)) y: (((size) / (100)) * (y))
end

Then I make it so it points in the direction of the variable “rot”.

Thanks!
nicos_revenge
Scratcher
36 posts

How to change center of rotation midgame?

you can change the position of the sprite costume relative to the 0x0 of the cavas that way they can rotate around from itself or from a different position so that it circles around like the earth around the sun
Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

How would I put that in a script?
han614698
Scratcher
1000+ posts

How to change center of rotation midgame?

Detroitman200 wrote:

How would I put that in a script?
You wouldn't.

This is not possible on Scratch, sorry.

Sorry, you have to wait 60 seconds between posts.

<Scratch Wikian // 2000+ Edits | Forum Helper // 7000+ Posts | Scratcher // 530+ Followers>


banner coming soon…
awesome-llama
Scratcher
1000+ posts

How to change center of rotation midgame?

It's a bit complicated. You can either do it mathematically or do it with a bunch of movements below:



NOTE: This is a screenshot of a script I use in my unreleased ship simulator. There are a couple of blocks which don't apply to you. The concept is what's important.
Anywhere that the ship is mentioned, that is the centre of rotation.
What the script does is basically:
  1. put the sprite in the correct x and y offset (from the custom centre of rotation)
  2. get its distance between the custom centre of rotation and the actual centre of the sprite.
  3. Point towards the custom centre.
  4. Go to the custom centre (in my case it is 0,0, but it could be anything)
  5. Turn based on how much you want the sprite to rotate around the centre.
  6. Move backwards from the custom centre of rotation so the original one is offset.
  7. Point in the direction you want to display the sprite in.

Last edited by awesome-llama (June 8, 2021 19:53:24)



Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

So I would make it so It goes to the center point then rotate and go back?
Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

Image… This is what I want to do… I want to make the center of rotation as the position of the object, like a camera.
Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

Sry image didn't show up. How do I paste my own image into this?
MasterofTheBrick
Scratcher
1000+ posts

How to change center of rotation midgame?

Detroitman200 wrote:

Sry image didn't show up. How do I paste my own image into this?

You will have to use a media service such as ImageShack to upload your photos, copy the link, then use the picture extension (Ctrl + P) to paste the link into your forum post.
Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

OK! Thanks!
Detroitman200
Scratcher
14 posts

How to change center of rotation midgame?

Sorry, can do it, but in the middle of the board, it rotates just fine. But that's because that's the center of rotation. When I move farther, the edge rotates around the center, taking the floor off below me. Does anybody know how to fix that?

Project

Go to the edge of it and you'll see what happens when you rotate the camera. I need to make the center of rotation the position of the camera so the floor doesn't go away from me. If so, could somebody send me a project with the correct script?

Last edited by Detroitman200 (June 10, 2021 11:56:47)

Powered by DjangoBB