Set rotation speed for "motion" category
-
There should be a rotation speed for the motion category when sprites point at objects that could potentially move. I think this would be an easy way for them to demonstrate top-down weight physics
-
@011830-0a42ef84 you could have instead when it turns to face an object, you caclulate the direction it’ll go and if that direction is higher than the rotation speed, turn the rotation speed, but if it’s less you just turn the direction. Also top down physics are quite possible with gravity being 0
-
@tyller_ I tried, but I’m bad at the physics stuff. I work with the original category blocks.
Also, I need a visual on what you said otherwise it doesn’t make much sense to me anyways
-
@011830-0a42ef84
It may seem a little complex, but I can explain it all if you want -
@tyller_ Well, right now on my tower defense game, I need help with measuring if there are no enemies on the screen, then a trigger will happen where everything stops firing. It’s set up to where the enemies will keep firing forever if they sense an enemy, but it’s bugged to where the game will only sense “no enemies” when the wave ends.
Nevermind I fixed it
-
@011830-0a42ef84 you can add a counter for how many enemies have spawned that goes up when they spawn and down when they exit/get shot
-
Can you explain a bit more what’s this new block would do? Is it a speed limit on how fast the object can rotate?
Do you think you can try to calculate how many degrees the object will rotate in total? If so, then you can calculate how long it should take based on the desired rotation speed, then you can use the following block to do the rotation:
-
@info-creaticode Yes but I need to target a continuously moving object.
-
@011830-0a42ef84 are you sure you want them to turn at a limited speed? you should just have them point towards the object at all times in the context of tower defense, turn speed isn’t really something to have (especially without projectile collision stuff)
-
Can you share the project? Are you saying the target object is moving, and your sprite keeps rotating to face that target, but you don’t want your sprite to rotate too fast?
-
@tyller_ yes, but some units have heavier weapons like the mini gun, there-fore harder turning speed
-
@011830-0a42ef84 the issue is you’ll need projectile/bullet speed first (or just detections on if a unit is pointing at an enemy so when it shoots it should actually damage an enemy)
-
-
Thanks. So, which sprite and which code blocks for that sprite are you trying to improve?
-
@info-creaticode On the minigun and launcher units, their turning automatically points to the fastest enemy. I would like there to be a turning time that is slower than just automatically pointing at them.
I would also like to know how for units to point at the first enemy, not just the fastest one.
-
Can you add some instructions in the project cover page to explain how to play the game? What are the keyboard or mouse controls?
-
@info-creaticode The instructions are in the actual game, since that version is the test room, so it doesn’t include instructions
I moved the test room’s download to the actual one, you should see the instructions in that one.
https://play.creaticode.com/projects/672e66b5731b37123597e815
-
This is a fun game.
So let’s solve one problem at a time. To limit the rotation speed, you can try to use a loop to repeatedly rotate the sprite a little bit towards the target’s direction.
Here is a demo project:
play.creaticode.com/projects/67351d4fef35162a42f8bc50
As you can see, in a forever loop, we take 3 steps:
- calculate angle difference between current direction and the desired direction
- normalize that difference to within -180 and 180
- rotate for up to the speed limit
This is what you will get as you move the mouse: