playMaker

Author Topic: 3d Chopping trees/hitting rocks etc.  (Read 1419 times)

FrankDePaul

  • Playmaker Newbie
  • *
  • Posts: 25
3d Chopping trees/hitting rocks etc.
« on: January 02, 2018, 10:20:59 AM »
Hey all!

I am looking for some direction on a few mechanics. I have a 3d game, 3rd person view. I am able to walk around and I can even detect when I am near a tree and begin the chopping animation if I left click.

I think I am going about this incorrectly. There are a couple issues I have. The first issue is the tree does not know it is being chopped. The second issue is the direction my player is facing. I currently use a trigger with a tag to let the player know they are in the area of the tree. If the player left clicks the chopping animation starts. This even happens if the player has back up to the tree or is right next to it.

What would be better is if the tree they clicked on with the mouse was selected and the player had to be facing it to chop it. This would be the same with ore, rocks, etc.

Any tips or links to tutorials would be appreciated. I have looked at a lot of tutorials to try and combine different mechanics but am a bit lost.

Thanks!

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: 3d Chopping trees/hitting rocks etc.
« Reply #1 on: January 03, 2018, 10:12:28 PM »
If I would do something like this maybe I'll do it this way:

Tree is a prefab with a full&chopped models, collider and an fsm. When a tree got clicked fsm do
a) check if "already chopped" and don't do anything if yes
a) check if player near, and if yes - rotate player to the tree
b) run player "chopping" animation
c) change the model to "chopped" state (hide full tree & show chopped model)
d) add wood to the player variables (or whatever it should does)
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: 3d Chopping trees/hitting rocks etc.
« Reply #2 on: January 05, 2018, 08:49:38 AM »
Hi.
pigglet gave a good idea and maybe not only rotate to the tree but also move (walk) to the right position (distance) can be done so you would have a clean animation.


But this kinda depends also on how you want it to work.

You could for example also do it Minecraft style and use a raycast (forward from the player) when you click to Chopping button.
If the raycast sees the tree (use the distance from the raycast or when inside the trigger from the tree) then start chopping and send/get data to/from the tree that it is being chopped.

On the tree you can have one or some fsms to handle the tree animations and data.