sitefin.blogg.se

Cult of the lamb gems
Cult of the lamb gems














This is the final gameobject’s structure:ĭrag this WeaponItem gameobject to the prefabs folder to create a prefab of it. Set the collider to be a trigger and freeze all rotations and positions in the Rigidbody Attach the WeaponItem script and also add a Collider (a Sphere collider in my case) and a Rigidbody. (_weapon) ĭrag a weapon sprite into the scene. If (("Player") & other.TryGetComponent(out PlayerStateMachine stateMachine)) Private void OnTriggerEnter(Collider other) _rigidbody.AddForce((Vector3.up + Vector3.right) * force, ForceMode.Impulse) Public void CreateInstance(WeaponSO weapon, float force) _spriteRenderer.sprite = _weapon.WeaponSprite This will help to attach any weapon to the player when touched. Now we need to create a script that will help putting this weapon data into the scene. Drag the previously made prefab (Weapon 1 above) in the Prefab field and adjust the other values to your liking. Name it Weapon 1.Īfter that, modify the properties of this weapon data according to your weapon. In the Projects view right click and create a new Weapon data asset. Public Bounds GetBoundsRelativeToPlayer(Transform player) This script will hold each weapon data and will also help calculate the bounds of an attack relative to the player’s position. Now let’s create a scriptable object that holds our weapon data. Repeat the same steps for each weapon you have. Drag the roots gameobject (Weapon 1) to the Prefabs folder to create a prefab of this weapon.

cult of the lamb gems

In our case the sword was only 1 sprite but this is useful if we need to add more sprites or even a TrailRenderer to follow the movement. Create 2 nested gameobjects inside to put a Sprites holder and inside this one the actual sprites of the weapon. Create an empty gameobject and name it Weapon 1.

cult of the lamb gems

We need to create a weapon game object as a visual of to show the players. I made sure to set the pivot somewhere in the handle of each sprite (the little blue circle in the handle you can see on the sprite to the left) For this case I’m going to use this 2 different sprites. The first thing we need is some weapon sprites.

#Cult of the lamb gems series#

If you want to follow along the series you need to first read Ground Zero, Part 1, Part 2, Part 3, Part 4 and Part 5. This is the fifth tutorial of the making of the Cult of the Lamb mechanics in Unity.














Cult of the lamb gems