How to change a variable when touching a pen drawing? - mit-scratch

I'm making a game in Scratch where if they touch something their HP goes down. I'm planning on making multiple of the sprite appear without having to use clones or make several of the same sprite so I'm using the pen extension to draw it. I'm running into a problem though. When I tell it to change the variable by touching the sprite, the pen copy doesn't count as it so it won't change it. How do you make the variable change when touching the pen?
The main reason I don't plan on using clones is due to Scratch's 300 clone limit. I intend on having more than 300 of the thing i'm making, which would go over Scratch's clone limit and why most people use the pen to get around that. The answer marked as accepted technically solves the problem until that point so I marked it as correct.

For the sake of providing a formal answer to this question, I'll just rehash the comments above.
A solution that worked ended up being to create an invisible (via the ghost effect) clone that goes over each pen drawing - each clone acting like a hitbox.

Related

How to make my cinemachine stop from shooting into outer space?

Im learning game developing and am now entering the camera follow subject, scrolled through a few tutorials and learned that I need a unity built-in utility called the Cinemachine, the concept seemed easy and I was pretty excited about implementing the cool camera following mechanism, but somehow, whenever I set my cinemachine follow target to the player(after adding the pixel perfect extension), it just keeps shifting my players coordinates, whether it being the x y or z ones, once it starts it cant even be stopped, as the only solution was to keep spamming CTRL+Z and reset it...(making a 2D game btw)
I tried changing some of the tags or changing the following target but all to no avail, even with other components, as long as I made it follow smth it would just disappear literally...
Expected some changes pr at least an improvement if I put other settings, but yea, sadly it didnt work

Unity Engine. Rotation calculation issue. Rigidbodies and rotation with an object

I´ve got some problems with rotations. So, I´ve got a ship, imagine it as a container, I´m trying to get everything within that container to follow the position and rotation of that container. These internal objects are also rigidbodies that can freely move.
So imagine that within the ship there is a table and a cup, both objects rigidbodies. If you are within the ship you can push over both objects, but while the ship moves, it will "drag" them with it.
So the table and cup have to always stay in the correct position, no matter how much the ship moves and rotates. And to clarify, I won´t be able to parent them either, they have to stay separate in this case. Hope I explained that right!
So, for now, I was able to achieve the detection of objects within the ship and follow correctly the position. But the rotation, using rotateAround three times with each axis (Which in itself might be incredibly wrong already lol) even though it seemingly works, it´s always slightly off. And on bigger rotations just breaks fully.
Which does make sense I guess but I still don´t manage to think of a way to get this to behave right.
Is there any way to achieve this?
Thanks for any help!

Clone subobject/face without moving

I've spent about 20 minutes searching for this to no avail. All I want to do is create a double sided face for a shop sign for example.
I create a face that sticks out from the building, and I obviously want it double-sided, so I want to simply clone the face and flip the normal.
I know I can do this holding shift and translating the face, but then I have to move it back. I know that you can do this for an object in the edit menu, just selecting clone object, but it doesn't seem to work for sub-objects (ie., faces).
Also, when I searched for how to make a face double-sided, most suggestions were to change the renderer settings to change the face culling, or to apply a double-sided material. But, neither of these methods actually create a new face, do they? For example if I were to export it to my OpenGL project, exporting it wouldn't create the extra face vertices, would it?
Thank you.
Edit: I've been thinking, I know there are many ways to achieve this, I just thought I could detach the face to its own object, clone it in its place, flip the normal, and then attach the two objects to the original again, but the workflow is supposed to be easy.
Thanks.
OK, I've been playing around a bit, and found out that you can
1: Select the face.
2: Click Detach.
3: Select Detach As Clone.
4: Select Detach As Element if you want it to stay in the same object.

Scratch Cloning duplications

I am using scratch. I am cloning sprites and I am making a minecraft type game where I use many clones of one block to make the workload easier. I keep the original sprite hidden, and hide clones when I want to destroy them. I am trying to create new clones by moving the original sprite to the location where I want the clone, cloning the sprite, and then hiding the sprite and showing the clone. But, it appears as if the code for placing new sprites squares the number of clones placed and brings all of them to the character. I am new to this community and just began learning scratch. If there is a way to show the scratch code I would be happy to. Thanks.
What I think you'll find is that the code is calling for 'the sprite' as in the original and all clones of itself to move to the center, as the code runs for each instance (clone) of the sprite, hence causing it to replicate itself for every existing instance of the sprite.
What you would probably have to do is have an external script within the scene, or another sprite that has no clones, call the sprite in order to clone it, as I am fairly sure that scene behaviours can facilitate cloning of other sprites. From there, I would have it set some sort of global variable to the co-ordinates you want it to spawn at, and add a script for the sprite that makes it move to the co-ordinates specified by those variables when it is created.
Since you linked your project, I'll see if I can create a remix for it that fixes your problem tomorrow if the problem is still there.
Scratch has a clone limit of around ~ 301.
When you want to delete a clone, I suggest using the 'delete clone' block. If you think the screen needs to display more than 300 clones, you may have to use a method called stamping, where you store every x position on one list, every y position on another list, then render every position using a custom block. how to make it | example of the code
If you could screenshot your code, I could help debug it. I won steal it, so don't worry. And in case you're wondering, I've been been on Scratch for two years.

Drawing continuous lines on Xcode/Unity

I am making a app which draws continuous lines like a snake using Unity and SKSpriteKit (Obj-C) in Xcode (I’m making 2 versions of the same app in both):
http://i.stack.imgur.com/qA1zk.png
http://i.stack.imgur.com/484kj.png
http:// i.stack.imgur.com/QTEkC.png (Apologies for the image posts. I can't post an image/more than 2 links)
If you’ve ever heard of a game called Curve Fever, what I’m doing here is quite similar to it. I’m controlling the direction of the end of the line with the arrowkeys, whilst the end of the line automatically moves forward every frame creating an image like the one above.
However, from the 3 screenshots above, it is quite obvious that my program isn’t very efficient - every frame, I add a circle sprite to the SKScene in the place where my moving sprite is, which is why, after a while, there are over 1000 nodes on the screen, and the energy impact/memory/cpu is very high… Not ideal.
So now I’m looking for better ways of drawing the line on the screen without drawing thousands of nodes.
A while ago, a friend talked to me about how he made a similar app in GameMaker (which I have no knowledge of how to use). When I asked him how he rendered the line, he said he created something called a “surface”, and when anything moved on that surface, the old position of the sprite would still stay there - which would create lines if a circle moved across the surface.
He was rather vague about this, and I tried to do some research later, but with no success. I couldn’t find anything relevant about continuous lines, surfaces and GameMaker, Xcode or Unity.
If someone could come up with a solution like my friend was talking about, for Xcode/Unity - preferably both (or if someone could tell me what he was talking about for GameMaker), then I’d be grateful, as this would optimise my game and reduce the severe lags I get after around 30 seconds.
Also, I’d be grateful if anyone could suggest alternative solutions to this, too.
I'm using GameMaker but I have no knowledge of Xcode or Unity. I can't help you directly but I can explain GameMaker surfaces.
Surfaces in GM are objects where you can draw on instead of directly drawing on the screen. Later you can draw the surface to the screen. The main advantage of it is that you can store a surface and for example draw it again in another tick, while the screen is redrawn in every tick, or that you can change it over time.
Surfaces are basically just bitmaps where you draw on. That means it wouldn't be hard to do the same in any other environment. Most other libraries/APIs call it canvas.
In your example you would draw one circle to the bitmap in each tick and then draw the whole bitmap to the screen.
A related topic is destructible terrain as it is discussed here: https://gamedev.stackexchange.com/questions/6721/implementing-a-2d-destructible-landscape-like-worms