Search Unity

Woodcutting/Mining proffessions. Does anyone know of a good guide?

Discussion in 'Scripting' started by zXSmashXz, Nov 5, 2014.

  1. zXSmashXz

    zXSmashXz

    Joined:
    Nov 2, 2014
    Posts:
    15
    I am looking for help on adding professions into my RPG Project. I need someone to point me in the right direction. I want to be able to cut down a tree, receive a log, and have the tree to re-spawn after some time.

    I am new to unity scripting but I kind of understand the basics. But what I don't understand is what functions to use for doing these actions. Any help is appreciated thanks in advance:)

    I think I need to use raycast for making the player cut the tree, am I right on this?
     
  2. Stoven

    Stoven

    Joined:
    Jul 28, 2014
    Posts:
    171
    Is your game 2D or 3D?

    You may not need to use Raycasting just to detect the object. For example, you could have a Collider surrounding the tree with isTrigger set to true, and if your character is close enough to the tree (and also assuming your character has a Rigidbody and Collider attached), the trigger can notify your character that it's closeby using OnTriggerEnter( ). From there, you can notify the Character and let them know that they're close to that tree (sending the GameObject to the character through the OnTriggerEnter function).

    Once you get this far, you can explore other options.

    [Snipped: Overcomplicated the problem]

    You could use Raycast as well, but for this kind of problem it may be better to use Triggers/Events as opposed to casting a ray to detect if you're close to something to be able to perform an action upon it. I would use Raycasts for more refined controls such as detecting the normal/position of the surface I made contact with so I can move a certain way, etc.
     
    Last edited: Nov 5, 2014
  3. zXSmashXz

    zXSmashXz

    Joined:
    Nov 2, 2014
    Posts:
    15
    Thanx for the reply, I will get back to you when I try this out.