Unity-Technologies / UnityPlayground

A collection of simple scripts to create 2D physics game, intended for giving workshops to a young audience
MIT License
870 stars 164 forks source link

TakeBall Action #3

Closed Bryan-Legend closed 6 years ago

Bryan-Legend commented 7 years ago

My kids tried to make a quiddich game. Here's a quick action that I coded up for it.

using UnityEngine;
using System.Collections;

public class TakeBall : Action {

    public override bool ExecuteAction(GameObject other)
    {
        other.transform.SetParent(transform);
        other.GetComponent<Rigidbody2D>().isKinematic = true;

        return base.ExecuteAction(other);
    }
}
ciro-unity commented 7 years ago

Yeah, I've been thinking of a way to pick up an object and carry it around. But how would you release it? Maybe on collision?

Bryan-Legend commented 7 years ago

If an enemy player knocked into the ball they would steal it. Or it would get destroyed at the goal.

Should probably be called AttachChild or something. And should check for the existence of the rigidbody.

ciro-unity commented 7 years ago

AttachChild seems like a very technical name for kids who have never done game development. AttachObject is already better.

I'm also wondering if it could be made into one Action class to both pick up and release objects (and decide what it does by using a flag or a enum) for the sake of ease in maintaining the code. Or would it be better to have 2 separate Actions? 🤔

This project poses so many moral doubts!

Bryan-Legend commented 7 years ago

Maybe just name it Attach.

I'd keep it simple and make two actions.

On Thu, Dec 1, 2016 at 10:13 AM, Ciro Continisio notifications@github.com wrote:

AttachChild seems like a very technical name for kids who have never done game development. AttachObject is already better.

I'm also wondering if it could be made into one Action class to both pick up and release objects (and decide what it does by using a flag or a enum) for the sake of ease in maintaining the code. Or would it be better to have 2 separate Actions? 🤔

This project poses so many moral doubts!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/UnityTechnologies/PlaygroundProject/issues/3#issuecomment-264233653, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4KOB515QK8mmf5cc9JaY5OTOnN6AsHks5rDwBHgaJpZM4LA3sA .