Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Krauser1129 on August 26, 2020, 04:36:30 AM
-
So I have it set up to spawn a bullet that throws itself forward when left click is pressed. I want to add a random rotation that's a variable to the bullet when it's spawned to simulate accuracy. Do I have the FSM on the bullet tell it to have a random rotation once it spawns or is there a different way to do it on the gun FSM itself, right after or before Create Object?
-
Hi.
Both can work, but personally i would prefer the gun to handle it.
When you Create the bullet store it in a variable.
Then parent it to the tip of the gun
Then set rotation and position to 0,0,0
The bullet should point forward from the gun, if not adjust the bullet prefab mesh/sprite.
is the game 2d or 3d?
You can use for example a random float (or 2 random floats when 3D) and use those to set the rotation.
Then for 2D use 'Set Forward Velocity' and for 3d use Set Velocity and set Space to Self.
Btw for bullets its best to use pooling instead of create/destroy.
-
@djaydino
So I just go Create object, store it as a variable, then do random rotate with a range to the variable that is my object, and it'll spawn it? And thanks so much for answering so quickly!
-
Hi.
Create object will spawn it.
Then position it to where you want it.
Then do velocity.
if you want constant speed, set drag to 0 on the rigidbody.
-
I'm aware of the velocity, but I'm unsure how to exactly use random rotate. Would you mind explaining it real fast? Do I do create object first, store as variable then do the random rotation?
-
Hi.
Here are 2 samples (for 2D and 3D)
(https://i.imgur.com/rh94puA.gif)
(https://i.imgur.com/E5oPvcg.gif)
-
Is there any way to pause these? lol
-
Holy crap, thank you so much! This is amazing! This solves so many issues for me!