Cineamatic camera, event system, and folower ai. Contains quasi tutorial

upbge
(Camos1011) #21

I can change it myself.
I’m pretty confident as of late but, I’d need to know which line to put it, what game properties are attached and how it’s meant to work and I’d be set.

0 Likes

(CYNIC78) #22

Are you planning to add enemy ai and some kind of combat mechanic driving with python in this template?

0 Likes

(Camos1011) #23

Yes! I have plans for enemy ai and a combat system similar to Manhunt with cinematic attacks rather than real-time ones and I’ve sorted out how I’d do that already unless it doesn’t work out.

1 Like

(Cortu) #24

Your line numbers might not be exactly the same as mine.

First get the smove game property off the trigger.
gryCine.cineCam.CineamaticTrigger.__init__, line 24

self.smove = self.get('smove', 100)

Then when theres a collision you should send the smove property with a camera message.
gryCine.cineCam.CineamaticTrigger.collision, line 37

gry.msgr.say('cameraPost', [hitObj, self.pivot, self.pivotType, self.dist, self.offset, self.lens, self.smove], 'camera')

Finally, when the camera receives a camera message, it sets its smove property based off the message.
gryCine.cineCam.CineamaticCamera.message, line 55

self.pivot, self.pivotType, self.dist, self.offset, self.lens, self.smove = args[1:]

Theres going to be a problem that after teleporting, you will need to hit a new camTrigger almost immediately, in order to reinitialize smoving.

By the by, Blender Artists is telling me I misspelled smove. My spelling is atrotius. Its a know isue.

0 Likes

(Camos1011) #25

Does it have to be done on every trigger for the project to play? If not, I think it’s real close but, there’s a lot of errors and they happened even before getting rid of ‘smove’ on cineCam so, now I’m lost.
I followed everything and nothing.

https://www.mediafire.com/file/3vs4df8sz1vlzax/cineCam_teleport_smove_error.rar/file

Error report:

Error: sub(Cube CamTrigger), Python script error
Traceback (most recent call last):
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 22, in sub
    clss = gryLib.fromModImportAttr(mod, clss)
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 58, in fromModImportAttr
    mod = import_module(mod)
  File "C:\Users\...\OneDrive\Desktop\Release\2.79\python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gryCine.cineTrigger.CineamaticTrigger'; 'gryCine.cineTrigger' is not a package
Error: sub(HallRoom CamTrigger), Python script error
Traceback (most recent call last):
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 22, in sub
    clss = gryLib.fromModImportAttr(mod, clss)
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 58, in fromModImportAttr
    mod = import_module(mod)
  File "C:\Users\...\OneDrive\Desktop\Release\2.79\python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gryCine.cineTrigger.CineamaticTrigger'; 'gryCine.cineTrigger' is not a package
Error: sub(CineCam), Python script error
Traceback (most recent call last):
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 33, in sub
    else:  return clss(obj, *args, **kwargs)
  File "F:\...\...\...\Blender Projects\cineCam ...\gryCine\cineCam.py", line 24, in __init__
    self.smove = self.get('smove', 100)
NameError: name 'self' is not defined
0 Likes

(Camos1011) #26

I was able to get an smove script attrubute added to the Teleport.py script in the project (not the gryTrigger one) to work. Thing is the guy that helped me doesn’t know how the script works fully to make the camera jump-cut to the teleport room but, he made it go faster but, not fast enough.
Maybe you could take a look at it?

https://www.mediafire.com/file/c5ncozkdq1y47c6/cineCam_teleport_py_smove_script.rar/file

0 Likes

(Cortu) #27

gryCine.cineTrigger.CineamaticTrigger.__init__ shoud be gryCine.cineTrigger.CineamaticTrigger
This should point to the class object itself.

Check line 46 in teleport.py. Iv never used two equals signs on the same line before, so I’m not exactly sure what that line is supposed to do. Removing it seems to fix the problem.

The main purpose of this code was to make something that is easily expandable by using subclassing. I don’t really know how to make a complex video game without objects. If your not interested in using oop, then this code may not be appropriate for your project.

0 Likes

Could anyone help me with sending the camera back to main?[SOLVED]
I need help with a camera that suddenly warps with the character seemlesly[SOLVED]
(Camos1011) #28

Well!
That was a simple fix!
As for Object Oriented Programming, I thought that’s what this was.

I use whatever works, your project works perfectly except for that one major but, small teleporting and camera issue.
Beyond that OOP is perfect for what I need.
My project is so dynamic that I can’t really be picky with what to use and not to use.
Thanks! You’ve helped a lot.

0 Likes

(Camos1011) #29

Okay, figured out what the last line was meant to do.
It was meant to send the camera back to the main camera.
It won’t return to the main camera.
I even tried having a an extra object in the main hall to have it switch back and nothing.
It’s doesn’t seem easily expandable to me either.

0 Likes

(Camos1011) #30

Okay! I guess I keep underestimating my skill :blush:
All I had to do was make a second script on the teleport end location to set it back to the main camera :).
It’s a more clever camera system than I realized!
I would add it to the teleport code but, I just keep breaking it when I try.


import bge
import random

cont            = bge.logic.getCurrentController()
scene_objects   = bge.logic.getCurrentScene().objects
own             = cont.owner

# get sensors
collision   = cont.sensors['Collision']

camera = bge.logic.getCurrentScene().active_camera
camera_controller = camera.parent
camera.timeOffset = camera_controller["smove"] = 100.0

I even tested camera changes to see if it returned and it did.

Also, there is an AI issue.
I set up “aiFollower.py” to where when you begin playing the follower instantly begins following you and when you switch to unDood the main follows as expected automatically but, when I switch back to main unDood no longer automatically follows anymore.
I don’t get it. Is this a bug?
Here’s my setup

import gryLib as gry
import bge
# facing on steering is broken with charature pysics.  use a facing acuator.
# you cant have multi layer nav meshes
# make shure your navmeshes overlap a little so the char can transfer betwene them
class AiFolower(gry.BaseSubClass):
  """
  an ai that will follow the active char
  """
  from gryLib import child
  def __init__(self):
    """
    self.child('Eye'):  this is used for visablity checks
    """
    self.steer = self.actuators['Steering']
    self.track = self.actuators['Edit Object']
    self.steering = True
    self.eye = self.child('Eye')
  
  def input(self):
    """
    if self is active send messages to other folowers
    keys.folowme:  gry.msgr.say('follow_me', [self])
    keys.staystill:  gry.msgr.say('stay_still', [])
    """
    #:  self['active'] is a state to determine if the char should acept keybinds
    if not self.get('active', True):  return
    keys = gry.keys
    
    #:  send messages to the folower
    if keys.gothere.activated and True:
      #:  this currently dosnt work
      import bge
      point = self.scene.active_camera.getScreenRay(bge.logic.mouse.position[0], bge.logic.mouse.position[1])
      print(self, ': go there')
      gry.msgr.say('go_there', [point])
    
    if keys.seeme.activated:
      print(self,': can you see me')
      gry.msgr.say('can_you_see_me', [self])
    
    if keys.folowme.activated:
      print(self,': follow me')
      gry.msgr.say('follow_me', [self])
    
    if keys.staystill.activated:
      print(self,': stay still')
      gry.msgr.say('stay_still', [])
  
  
  
  def ai(self):
    """
    runs steering
    """
    #:  self['ai'] is a state to dertermine if the ai should run
    #:  it seems like this needs to be run every frame
    if not self['ai']:  return
    self.steering = True
  
  def message(self, subject, args, filter, to, fromm):
    """
    currentChar
    navmesh
    follow_me
    stay_still
    """
    if fromm == self:  return
    
    #:  folow the current char, unless its self
    if subject == 'currentChar':
      if args[0] == self:  self['active'] = True
      else:
        self['active'] = False
        self.target = args[0]
    
    #:  set the navmesh to be used with a navmesh event
    if subject == 'navmesh':
      hitObj, navmesh = args
      if hitObj == self:  self.steer.navmesh = navmesh
    
    #:  these should only be done if the char is not active
    if self.get('active', False):  return
    
    #:  broken
    if subject == 'go_there':
      print(self, ': cant do that yet')
    
    #:  folow the target
    if subject == 'follow_me':
      self.target = args[0]
      self.steering = True
      print(self, ': will follow ', args[0])
    
    #:  stop folowing
    if subject == 'stay_still':
      self.steering = False
      print(self, ': will stay still ')
    
    #:  broken
    if subject == 'can_you_see_me':
      print(self, ': cant do that yet')
      
  
  # raycast should have a setting to ignore ghoasts # obj.isSuspendDynamics seems to sometimes work
  def see(self, target):
    hitList = gry.rayChain(self.eye, target.eye)
    hitList = [obj for obj in hitList if not obj.isSuspendDynamics]
    return hitList
  
  def hear(self, target):
    pass
  
  @property
  def aiRun(self):
    """
    tells if the ai is currently running
    """
    if self['ai'] and not self['active']:  return True
    if not self['ai'] and self['active']:  return False
    else:  raise KeyError(  'self[ai] is '+str(self['ai'])+' while self[active] is '+str(self['active'])  )
  @aiRun.setter
  def aiRun(self, bool):
    if bool:  self['ai'] = True;  self['active'] = False
    else:  self['ai'] = False;  self['active'] = True
  
  @property
  def steering(self):
    raise NotImplementedError ('it would appear that actuators do not have to test for activations.  concidder using actuator sensor insted ')
  @steering.setter
  def steering(self, bool):
    """
    turns steering on or off
    """
    cont = bge.logic.getCurrentController()
    if bool:
      cont.activate(self.steer)
      cont.activate(self.track)
      self['ai'] = True
    else:
      cont.deactivate(self.steer)
      cont.deactivate(self.track)
      self['ai'] = False
    
  @property
  def target(self):
    return self.steer.target
  @target.setter
  def target(self, target):
    """
    the object the ai is folowing
    """
    self.steer.target = target
    self.track.object = target


0 Likes