Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
public class GrapplingGun : MonoBehaviour
{
public Transform gunTip; // Transform of the grappling gun's tip
public LayerMask grappleLayer; // Layer mask for objects that the grappling gun can attach to
public float grappleSpeed = 10f; // Speed at which the player is reeled in by the grappling gun
private LineRenderer ropeRenderer;
private Vector3 grapplePoint;
private SpringJoint springJoint;
private bool isGrappling;
void Start()
{
ropeRenderer = GetComponent<LineRenderer>();
}
void Update()
{
if (Input.GetMouseButtonDown(0) && !isGrappling)
{
StartGrapple();
}
else if (Input.GetMouseButtonUp(0))
{
StopGrapple();
}
}
void FixedUpdate()
{
if (isGrappling)
{
ReelIn();
}
}
void StartGrapple()
{
RaycastHit hit;
if (Physics.Raycast(gunTip.position, gunTip.forward, out hit, Mathf.Infinity, grappleLayer))
{
grapplePoint = hit.point;
springJoint = gameObject.AddComponent<SpringJoint>();
springJoint.autoConfigureConnectedAnchor = false;
springJoint.connectedAnchor = grapplePoint;
float distanceFromPoint = Vector3.Distance(transform.position, grapplePoint);
springJoint.maxDistance = distanceFromPoint * 0.8f;
springJoint.minDistance = distanceFromPoint * 0.25f;
ropeRenderer.enabled = true;
ropeRenderer.SetPosition(0, gunTip.position);
ropeRenderer.SetPosition(1, grapplePoint);
isGrappling = true;
}
}
void StopGrapple()
{
Destroy(springJoint);
ropeRenderer.enabled = false;
isGrappling = false;
}
void ReelIn()
{
float distanceFromPoint = Vector3.Distance(transform.position, grapplePoint);
if (distanceFromPoint > 1f)
{
transform.position = Vector3.Lerp(transform.position, grapplePoint, Time.deltaTime * grappleSpeed / distanceFromPoint);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour
{
public float speed = 20f;
public Rigidbody2D rb;
void Start()
{
rb.velocity = transform.right * speed;
}
void OnTriggerEnter2D(Collider2D hitInfo)
{
// Destroy projectile when it hits a target
Destroy(gameObject);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RapidFireProjectile : MonoBehaviour
{
public float speed = 20f;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
public Rigidbody2D projectilePrefab;
public Transform firePoint;
void Update()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Shoot();
}
}
void Shoot()
{
Rigidbody2D projectileInstance = Instantiate(projectilePrefab, firePoint.position, firePoint.rotation);
projectileInstance.velocity = firePoint.right * speed;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MultiShotProjectile : MonoBehaviour
{
public float speed = 20f;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
public Rigidbody2D projectilePrefab;
public Transform firePoint;
public float angleStep = 45f;
void Update()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Shoot();
}
}
void Shoot()
{
for (int i = 0; i < 8; i++)
{
float angle = i * angleStep;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Rigidbody2D projectileInstance = Instantiate(projectilePrefab, firePoint.position, rotation);
projectileInstance.velocity = projectileInstance.transform.right * speed;
}
}
}
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np
import bpy
# Define the dimensions of the 3D models to be generated
latent_dim = 100
img_height = 64
img_width = 64
img_depth = 64
channels = 1
# Define the generator network
generator = keras.Sequential(
[
keras.Input(shape=(latent_dim,)),
layers.Dense(8*8*8*256),
layers.Reshape((8, 8, 8, 256)),
layers.Conv3DTranspose(128, kernel_size=4, strides=2, padding="same"),
layers.Conv3DTranspose(64, kernel_size=4, strides=2, padding="same"),
layers.Conv3DTranspose(32, kernel_size=4, strides=2, padding="same"),
layers.Conv3DTranspose(channels, kernel_size=4, strides=2, padding="same", activation="tanh"),
],
name="generator",
)
# Define the discriminator network
discriminator = keras.Sequential(
[
keras.Input(shape=(img_height, img_width, img_depth, channels)),
layers.Conv3D(32, kernel_size=4, strides=2, padding="same"),
layers.Conv3D(64, kernel_size=4, strides=2, padding="same"),
layers.Conv3D(128, kernel_size=4, strides=2, padding="same"),
layers.Conv3D(256, kernel_size=4, strides=2, padding="same"),
layers.Flatten(),
layers.Dense(1, activation="sigmoid"),
],
name="discriminator",
)
# Define the GAN model
discriminator.trainable = False
gan_input = keras.Input(shape=(latent_dim,))
gan_output = discriminator(generator(gan_input))
gan = keras.Model(gan_input, gan_output, name="gan")
# Compile the models
generator_optimizer = keras.optimizers.Adam(learning_rate=0.0002, beta_1=0.5)
discriminator_optimizer = keras.optimizers.Adam(learning_rate=0.0002, beta_1=0.5)
discriminator.compile(loss="binary_crossentropy", optimizer=discriminator_optimizer)
gan.compile(loss="binary_crossentropy", optimizer=generator_optimizer)
# Define a function to generate 3D models using the GAN model
def generate_3d_model():
# Generate a random noise vector
noise = tf.random.normal([1, latent_dim])
# Generate a 3D model from the noise vector
generated_model = generator.predict(noise)
# Reshape the generated model into a 3D array
generated_model = np.reshape(generated_model, (img_height, img_width, img_depth))
# Convert the 3D array to a Blender mesh object
mesh = bpy.data.meshes.new("GeneratedMesh")
mesh.from_pydata(generated_model.tolist(), [], [])
mesh.update()
# Create a new object and link it to the mesh
obj = bpy.data.objects.new("GeneratedObject", mesh)
bpy.context.scene.collection.objects.link(obj)
# Train the GAN model and generate 3D models at regular intervals
for i in range(1000):
# Train the discriminator on real and generated 3D models
real_models = ...
fake_models = ...
X = np.concatenate([real_models, fake_models])
y = np.concatenate([np.ones((len(real_models), 1)), np.zeros((len
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team